Running Flower using Supervisor

4.6k views Asked by At

Am having challanges starting flower using supervisor.

The following command in my development environment works on the console

celery --app=celery_conf.celeryapp flower --conf=flowerconfig

but moving to production to use supervisor am getting all sorts of errors

/supervisor/conf.d/flower.conf

[program:flower]
command=/opt/apps/venv/my_app/bin/celery flower --app=celery_conf.celeryapp --conf=flowerconfig
directory=/opt/apps/my_app
user=www-data
autostart=true
autorestart=false
redirect_stderr=true
stderr_logfile=/var/log/celery/flower.err.log
stdout_logfile=/var/log/celery/flower.out.log

With the above configuration, there is no error but all celery does is give me a help like output. Its like it doesn't acknowledge the variables passed.

 Type 'celery <command> --help' for help using a specific command.
 Usage: celery <command> [options]
 Show help screen and exit.
 Options:
   -A APP, --app=APP     app instance to use (e.g. module.attr_name)
   -b BROKER, --broker=BROKER
                         url to broker.  default is 'amqp://guest@localhost//'
   --loader=LOADER       name of custom loader class to use.
   etc..
   etc..
   etc...

Supervisor on the other hand throws INFO exited: flower (exit status 64; not expected)

I have other supervisor initiated apps using celery_beat and using the configuration file samples on github and they are working well with the same directory paths as above

The flowerconfig is as below:

flowerconfig.py

# Broker settings
BROKER_URL = 'amqp://guest:guest@localhost:5672//'

# RabbitMQ management api
broker_api = 'http://guest:guest@localhost:15672/api/'

#Port
port = 5555

# Enable debug logging
logging = 'INFO'

Solution:

Well, not really a solution so I haven't put it as an answer. Turned out there was a problem with my virtual environment. So I removed flower and installed again using pip3.4 as am on python3.4

Something to note though is that for flower to use your flowerconfig file, you need to add a director=/path/to/your/celery_config/folder/ entry in supervisor's /etc/supervisor/conf.d/flower.conf file else flower will launch with default settings.

/etc/supervisor/conf.d/flower.conf

; ==================================
;  Flower: For monitoring Celery
; ==================================
[program:flower]
command=/opt/apps/venv/my_app/bin/celery flower --app=celery_conf.celeryapp --conf=flowerconfig
directory=/opt/apps/my_app/celery_conf #this is key as my configuration file was in the `celery_conf` folder
user=www-data
autostart=true
autorestart=false
redirect_stderr=true
stderr_logfile=/var/log/celery/flower.err.log
stdout_logfile=/var/log/celery/flower.out.log

Thanks.

1

There are 1 answers

6
Chillar Anand On

Your supervisor is unable to locate celeryapp. My be your supervisor configuration file supervisor.conf is in different path.

You can pass directory option to supervisor process. So you can try

[program:flower]
directory = /opt/apps/venv/my_app/
command =  celery --app=celery_conf.celeryapp flower

This starts a new flower instance.

Also note celery conf and flower conf are different.