I'm trying to create a service that runs celery but I came across permissions problem. I saw in many tutorials that pidfile path is /var/run/celery/%n.pid but it seems like my user doesn't have rights to write to run.
When I start the service, this is what it returns:
PermissionError: [Errno 13] Permission denied: '/var/run/celery'
celery.service
[Unit]
Description=Celery Service
After=network.target
[Service]
Type=forking
User=master
Group=master
EnvironmentFile=/etc/conf.d/celery
WorkingDirectory=/home/master/myproject/
ExecStart=/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES} \
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
ExecStop=/bin/sh -c '${CELERY_BIN} multi stopwait ${CELERYD_NODES} \
--pidfile=${CELERYD_PID_FILE}'
ExecReload=/bin/sh -c '${CELERY_BIN} multi restart ${CELERYD_NODES} \
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
[Install]
WantedBy=multi-user.target
celery.conf
CELERYD_NODES="celery-worker"
CELERY_BIN="/home/master/.virtualenvs/myproject/bin/celery"
# App instance to use
CELERY_APP="myproject"
CELERYD_MULTI="multi"
# Extra command-line arguments to the worker
CELERYD_OPTS="--time-limit=300 --concurrency=3"
# %n will be replaced with the first part of the nodename.
CELERYD_LOG_FILE="/var/log/celery/%n%I.log"
CELERYD_PID_FILE="/var/run/celery/%n.pid"
CELERYD_LOG_LEVEL="INFO"
How to make it work?