21

I was configuring supervisor daemon to be able to start/stop Celery.

It did not work. After debuging back and forth I realized that the problem was that it did not change the working directory to the one mentioned in the directory option in supervisord.conf under program section.

Hopefully there is a workdir in Celery but I am curious - what is the purpose of the directory option then?

If you run a script via supervisor and print pwd it will output /.

1
  • You were lucky. I tried to launch Celery from another dir but with specifying workdir, it did not start. So better sit in the right directory and launch without workdir.
    – sekrett
    Dec 1, 2020 at 8:22

3 Answers 3

31

I had the same problem and managed to resolve it by reversing the order of directory and command options:

e.g. working:

[program:cat]
directory=/var/log
command=cat logfile

NOT working:

[program:cat]
command=cat logfile
directory=/var/log
1
  • supervisor version 3.1.3
    – acidjunk
    Feb 22, 2017 at 14:11
2

here is an example how i got nodejs app with correct ENV working with supervisor

[program:fake-smtp]
directory=/home/web/fake-smtp
command=sh -c 'NODE_ENV=production node src/index.js'
autostart=true
autorestart=true
user=web
redirect_stderr=true
stdout_logfile=/home/web/logs/smtp.log
stderr_logfile=/home/web/logs/smtp.err.log

i hope this helps! this app also requires correct directory.

2

It's the same with Laravel (PHP Framework), I'm using supervisor to run jobs in queue and the .env file was not found, here's a configuration that works:

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
directory=/var/www/YOUR_LARAVEL_APP
command=php artisan queue:work database --sleep=3 --tries=3
autostart=true
autorestart=true
user=YOUR_USER
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/YOUR_LARAVEL_APP/storage/logs/worker.log
stderr_logfile=/var/www/YOUR_LARAVEL_APP/storage/logs/worker_error.log

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .