diff --git a/README b/README index c2fb3e82..f0613e73 100644 --- a/README +++ b/README @@ -72,7 +72,8 @@ Basic commands: $ libra_worker --debug --nodaemon NOTE: When running the worker in daemon mode, you must make sure that the -directory where the PID file will be (-p/--pid option) exists and is writable +directory where the PID file will be (-p/--pid option) and the directory where +the log files will be written (-l/--logfile option) exists and is writable by the user/group specified with the --user and --group options. Also, the Python module used to start the daemon process does not like it when the PID file already exists at startup. diff --git a/libra/mgm/mgm.py b/libra/mgm/mgm.py index c2a895c5..66a77b16 100644 --- a/libra/mgm/mgm.py +++ b/libra/mgm/mgm.py @@ -265,6 +265,9 @@ def main(): except KeyError: logger.critical("Invalid user: %s" % args.user) return 1 + # NOTE(LinuxJedi): we are switching user so need to switch + # the ownership of the log file for rotation + os.chown(logger.handlers[0].baseFilename, context.uid, -1) if args.group: try: context.gid = grp.getgrnam(args.group).gr_gid diff --git a/libra/worker/main.py b/libra/worker/main.py index 904395a2..0dac3dfe 100644 --- a/libra/worker/main.py +++ b/libra/worker/main.py @@ -16,6 +16,7 @@ import eventlet eventlet.monkey_patch() import daemon +import os import daemon.pidfile import grp import pwd @@ -137,6 +138,9 @@ def main(): except KeyError: logger.critical("Invalid user: %s" % args.user) return 1 + # NOTE(LinuxJedi): we are switching user so need to switch + # the ownership of the log file for rotation + os.chown(logger.handlers[0].baseFilename, context.uid, -1) if args.group: try: context.gid = grp.getgrnam(args.group).gr_gid