I"m trying to figure out the best "architecture" so our django projects hosted on debian server could use celery and celery beat. He are my requirements:
Based on these requirements I came to these conclusions:
Under these circumstances, when I'm deploying NEW project, next to creating new linux user, setting up apache virtualhost etc., which Im doing as a root, I would also add new config file for supervisord, which seems OK to me. Then when Im deploying new version of project using Fabric im working only under project user.
The only unresolved problem (which I found until now) of this solution is that schedule configuration for celery beat is written in django settings, but beat deamon isnt able to recognize change in the configuration until it's reloaded. However project user isn't allowed to make the reload.
My question is how should I solve this problem or what other architecture would you recommend to me? Thank you.
Based on Chris's answer, the solution how to restart supervisord program without sudo permission: You have to edit supervisord.conf to change socket permissions (in my case located at /etc/supervisor/supervisord.conf]
[unix_http_server]
file=/var/run//supervisor.sock ; (the path to the socket file)
chmod=0766 ; sockef file mode (default 0700)
Then you have to make sure, that user who is written in config file is user who will restart program:
[program:projectx_celerybeat]
; Set full path to celery program if using virtualenv
command=/path_to_project_root/env/bin/celery beat -A main -s /path_to_project_root/celerybeat-schedule --loglevel=INFO
; remove the -A myapp argument if you are not using an app instance
directory=/home/xxx/project_root/celery_root/
user=YOUR_USER
numprocs=1
stdout_logfile=/path_to_log/beat.log
stderr_logfile=/path_to_log/beat.log
autostart=true
autorestart=true
startsecs=10
Then this command runned by YOUR_USER shoud work:
supervisorctl [stop/start/restart] [program_name]