Skip to content

Commit

Permalink
Merge pull request #349 from European-XFEL/log-privs
Browse files Browse the repository at this point in the history
Set the log file permissions *before* shutting down
  • Loading branch information
JamesWrigley authored Oct 24, 2024
2 parents be6ed9d + c45518b commit 904aad7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions damnit/backend/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ def listen():
file_handler.setFormatter(formatter)
logging.root.addHandler(file_handler)

# Ensure that the log file is writable by everyone (so that different users
# can start the backend).
if os.stat("amore.log").st_uid == os.getuid():
os.chmod("amore.log", 0o666)

log.info(f"Running on {platform.node()} under user {getpass.getuser()}, PID {os.getpid()}")
try:
with EventProcessor() as processor:
Expand All @@ -159,11 +164,5 @@ def listen():
# Flush all logs
logging.shutdown()

# Ensure that the log file is writable by everyone (so that different users
# can start the backend).
if os.stat("amore.log").st_uid == os.getuid():
os.chmod("amore.log", 0o666)


if __name__ == '__main__':
listen()

0 comments on commit 904aad7

Please sign in to comment.