From c8f8b5c07a80a47e922f024022b1c5635b1b93af Mon Sep 17 00:00:00 2001 From: Anuj Chauhan Date: Thu, 16 Apr 2020 21:34:56 +0530 Subject: [PATCH] Fixed Issue #6017: Changed the default paths for logs and pid files to be '/var/log/celery' and '/var/run/celery' Handled by creating the respective paths if not exist. Used os.makedir(path,if_exists=True) Updated the .travis.yml file. --- .travis.yml | 6 ++++++ celery/apps/multi.py | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 17e71778531..9099f0d95c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,21 +48,27 @@ matrix: - python: '3.8' env: TOXENV=flake8 + before_install: sudo mkdir /var/log/celery && sudo mkdir /var/run/celery && sudo chown travis /var/log/celery && sudo chown travis /var/run/celery stage: lint - python: '3.8' env: TOXENV=apicheck + before_install: sudo mkdir /var/log/celery && sudo mkdir /var/run/celery && sudo chown travis /var/log/celery && sudo chown travis /var/run/celery stage: lint - python: '3.8' env: TOXENV=configcheck + before_install: sudo mkdir /var/log/celery && sudo mkdir /var/run/celery && sudo chown travis /var/log/celery && sudo chown travis /var/run/celery stage: lint - python: '3.8' env: TOXENV=bandit + before_install: sudo mkdir /var/log/celery && sudo mkdir /var/run/celery && sudo chown travis /var/log/celery && sudo chown travis /var/run/celery stage: lint - python: '3.8' env: TOXENV=pydocstyle + before_install: sudo mkdir /var/log/celery && sudo mkdir /var/run/celery && sudo chown travis /var/log/celery && sudo chown travis /var/run/celery stage: lint - python: '2.7' env: TOXENV=flakeplus + before_install: sudo mkdir /var/log/celery && sudo mkdir /var/run/celery && sudo chown travis /var/log/celery && sudo chown travis /var/run/celery stage: lint - python: pypy2.7-7.3 env: TOXENV=pypy diff --git a/celery/apps/multi.py b/celery/apps/multi.py index 0c299a8cd3f..485654a3d87 100644 --- a/celery/apps/multi.py +++ b/celery/apps/multi.py @@ -140,8 +140,8 @@ def __init__(self, name, def _annotate_with_default_opts(self, options): options['-n'] = self.name - self._setdefaultopt(options, ['--pidfile', '-p'], '%n.pid') - self._setdefaultopt(options, ['--logfile', '-f'], '%n%I.log') + self._setdefaultopt(options, ['--pidfile', '-p'], '/var/run/celery/%n.pid') + self._setdefaultopt(options, ['--logfile', '-f'], '/var/log/celery/%n%I.log') self._setdefaultopt(options, ['--executable'], sys.executable) return options @@ -151,6 +151,8 @@ def _setdefaultopt(self, d, alt, value): return d[opt] except KeyError: pass + path_list = value.split("/") + os.makedirs("/".join(path_list[0:-1]), exist_ok=True) return d.setdefault(alt[0], value) def _prepare_expander(self):