Skip to content

Commit

Permalink
Fixed Issue celery#6017:
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hanchau committed Apr 16, 2020
1 parent e5158d9 commit c8f8b5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions celery/apps/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):
Expand Down

0 comments on commit c8f8b5c

Please sign in to comment.