graphite-project/carbon — pull request #156 by jamesjuran (2013-10-10 14:00:38+00:00)
Title: Chown created subdirs if USER specified [backport to 0.9.x]

Requesting backport of #150 which is now on master branch, so that if a 0.9.13 is done this will work correctly for distribution packages that set USER.

In a setup with:

LOG_DIR = /var/log/carbon and the
USER = carbon

If the --instance parameter is supplied to multiple instances of each daemon,
the daemon will create subdirectories of LOG_DIR like carbon-cache-a,
carbon-aggregator-b, etc. However, these subdirectories are owned by the
user starting the daemon, not by the USER= specified in the config file.
Only the console.log will be created, because all the other log files
are created after the daemon switches USERs.

This change makes the daemon chown() the newly-create directories to the
configured user if one is configured. To keep this simple, it now creates
only one level of directory, so you can no longer set
LOG_DIR=/path/does/not/exist and have that entire hierarchy get created.

This is related to graphite-project/carbon#149, as it a typical cause of
failing to open these log files.