Reputation: 1814
I am deploying a Django app to both production and staging environments (which happen to be in the same server). In order to do that, I run supervisord
with two different process for both environments.
Thus in my ansible-playbook
, I template my uwsgi config (according to the environment variables) and copy it to the /etc/supervisor/conf.d
folder.
Say I want to deploy the first time to a new staging environment. Since there are not any present config files, I would need to supervisorctl reread
and supervisorctl update
.
As I read from the docs:
When
state = present
, the module will callsupervisorctl reread
thensupervisorctl add
if the program/group does not exist.When
state = restarted
, the module will callsupervisorctl update
then callsupervisorctl restart
.
But does it mean I need to call both of them if I want to support both new staging instances and my current ones? Or is it enough to just use the state=restarted
? Or am I doing something wrong?
Would this code be ok? Or is it duplicating some information?
- name: Add uwsgi app (reread + add)
become: yes
supervisorctl: name={{uwsgi_app}} state=present
- name: Start uwsgi app (update + restart)
become: yes
supervisorctl: name={{uwsgi_app}} state=restarted
Upvotes: 1
Views: 2227
Reputation: 2722
You will need to either call both or set in your applications config files (the one you set in /etc/supervisor/conf.d
) for the application to start automatically by adding a line:
autostart: true
While it is true by default, I prefer to be explicit.
Upvotes: 2