Search code examples
djangosupervisordpython-rqdjango-rq

Starting rqworker using supervisor causes spawn error


Trying to start rqworker as stated in its README using this command:

python manage.py rqworker default

For some reason it gives ERROR (spawn error) and status shows FATAL Exited too quickly (process log may have details). Logs has no any information for error (exit status 1; not expected).

My supervisor configuration:

[program:rqworker]
user=ubuntu
directory=/var/www/project/
command=/var/www/project/venv/bin/python manage.py rqworker default > /var/log/project/rq.log
stopsignal=TERM
autorestart=true
autostart=true
numprocs=1

Running command directly from ubuntu user works as expected.


Solution

  • I submitted a PR on how to set this up on Ubuntu which may help you.

    https://github.com/W7PEA/django-rq/blob/4afc19ab9866882c1809f89f84066856c94d75c6/README.rst

    Deploying on Ubuntu Create an rqworker service that runs the high, default, and low queues.

    sudo vi /etc/systemd/system/rqworker.service

    [Unit]
    Description=Django-RQ Worker
    After=network.target
    
    [Service]
    WorkingDirectory=<<path_to_your_project_folder>>
    ExecStart=/home/ubuntu/.virtualenv/<<your_virtualenv>>/bin/python \
        <<path_to_your_project_folder>>/manage.py \
        rqworker high default low
    
    [Install]
    WantedBy=multi-user.target
    

    Enable and start the sevice

    sudo systemctl enbable rqworker
    sudo systemctl start rqworker