Supervisord: is there any way to touch-reload a child?
-
09-06-2021 - |
Question
I'm setting up a server to host a Django app which has:
uWSGI
app started by ubuntu's uWSGI init scriptceleryd
started bysupervisord
So I'm writing a deploy script which will:
- Pull code from git
- Migrate the DB
- Tell
uWSGI
to restart, so it will pick up the new code. - Tell
celeryd
to restart, so it will pick up the new code as well.
uWSGI
has this configuration feature:
touch-reload
gracefully reload the uWSGI stack when a file/directory changes.
So my script is run by the unprivileged user under which all the app's processes are run.
To restart uWSGI
I can simply touch ~/.restart_uwsgi
.
Is there any way I can do the same thing for celeryd
running under supervisord
without granting sudo access to the unprivileged user so he can supervisorctl restart celeryd
?
Solution
Since I still haven't found a better way to do this, here's what I'm doing right now:
# restart_my_proc.sh:
#!/bin/sh
supervisorctl restart <my_proccess_name>
chmod +x restart_my_proc.sh
# sudoers:
<site_user> ALL= NOPASSWD:/path/to/restart_my_proc.sh
# my_deploy_script.sh
sudo /path/to/restart_my_proc.sh
So I'm using sudo, not the best solution, but it works.
If someone has a better answer to this, I'll gladly change the accepted answer.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow