title: python django celery systemd
body: <p>I'm trying to build an NGINX/Gunicorn/Celery/RabbitMQ/Django server for several services.I am failed to do demonetization for celery.</p>
  
  <p><strong>My project directory below where celery is installed in virtualenv:</strong></p>
  
  <p>home/ubuntu/fanvault/bin/fanvault</p>
  
  <p><strong>My configuration file below in /etc/conf.d/celery</strong></p>
  
  <pre><code>CELERYD_NODES="w1 w2 w3"
  
  CELERY_BIN="home/ubuntu/fanvault/bin/celery"
  
  CELERY_APP="fanvault"
  
  CELERYD_MULTI="multi"
  
  CELERYD_OPTS="--time-limit=300 --concurrency=8"
  
  CELERYD_PID_FILE="/var/run/celery/%n.pid"
  CELERYD_LOG_FILE="/var/log/celery/%n%I.log"
  CELERYD_LOG_LEVEL="INFO"
  </code></pre>
  
  <p><strong>My celery.service in etc/systemd/system/</strong></p>
  
  <pre><code>[unit]
  Description=Celery Service
  After=network.target
  
  [Service]
  Type=forking
  User=ubuntu
  Group=ubuntu
  EnvironmentFile=-/etc/conf.d/celery
  WorkingDirectory=/home/ubuntu/fanvault/bin/fanvault/fanvault/
  ExecStart=/home/ubuntu/fanvault/bin/python3.5 -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=/home/ubuntu/fanvault/bin/python3.5 -c '${CELERY_BIN} multi stopwait ${CELERYD_NODES}  --pidfile=${CELERYD_PID_FILE}'
  ExecReload=/home/ubuntu/fanvault/bin/python3.5 -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
  </code></pre>
  
  <p><strong>My celery.py file in home/ubuntu/fanvault/bin/fanvault/fanvault</strong></p>
  
  <pre><code>from __future__ import absolute_import, unicode_literals
  import os
  from celery import Celery
  from datetime import timedelta
  from fanvault.settings import DEBUG
  
  if DEBUG is True:
      os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fanvault.local_settings")
  else:
      os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fanvault.aws_settings")
  
  app = Celery('fanvault')
  app.config_from_object('django.conf:settings', namespace='CELERY')
  app.autodiscover_tasks()
  app.conf.beat_schedule = {
  
      'pull_movie_home': {
          'task': 'movies.tasks.pull_movie_explore',
          'schedule': timedelta(minutes=3)
      }
  
  }
  
  app.conf.timezone = 'UTC'
  </code></pre>
  
  <p><strong>when I do "sudo service celery start" getting following error:</strong></p>
  
  <p>Job for celery.service failed because the control process exited with error code. See "systemctl status celery.service" and "journalctl -xe" for details.</p>
  
  <p><strong>When I do "sudo journalctl -xe" getting following:</strong></p>
  
  <pre><code>-- Unit celery.service has begun starting up.
  Apr 06 12:00:11 ip-172-31-53-174 python3.5[23368]:   File "&lt;string&gt;", line 1
  Apr 06 12:00:11 ip-172-31-53-174 python3.5[23368]:     home/ubuntu/fanvault/bin/celery multi start w1 w2 w3  -A fanvault --pidfile=/var/run/celery/%n.pid  --
  Apr 06 12:00:11 ip-172-31-53-174 python3.5[23368]:                                         ^
  Apr 06 12:00:11 ip-172-31-53-174 python3.5[23368]: SyntaxError: invalid syntax
  Apr 06 12:00:11 ip-172-31-53-174 systemd[1]: celery.service: Control process exited, code=exited status=1
  Apr 06 12:00:11 ip-172-31-53-174 sudo[23337]: pam_unix(sudo:session): session closed for user root
  Apr 06 12:00:11 ip-172-31-53-174 systemd[1]: Failed to start celery.service.
  -- Subject: Unit celery.service has failed
  -- Defined-By: systemd
  </code></pre>