David Prasad
David Prasad

Reputation: 61

Manage Supervisord process - Auto start on boot/Auto start upon it crash

We are using Supervisord for our apache server process monitoring.

So i would like to keep supervisor process always up for the below two scenarios:

  1. Autostart supervisor upon server reboot(Without init.d help)
  2. Autostart supervisor process upon it crashes while running.

We also have ansible installed.

It would be really great if someone can share their thoughts on it.

Upvotes: 0

Views: 6218

Answers (1)

13dimitar
13dimitar

Reputation: 546

I'll start with ansible - you can use it to install supervisor (example with apt module, use yum module if you have to):

- name: Install Supervisord
  apt: name=supervisor state=present update_cache=yes
  become: yes

and deploy the necessary supervisor configuration files (using the copy module).

- name: Deploy config file
  copy: src=yourconfigfile.conf dest=/etc/supervisor/conf.d/apache.conf mode=644
  become: yes

To autostart supervisor itself you need to just enable it (you can use the service module - enabled: yes). To have the supervisor controlled programs to autostart and autorestart, set the proper directives in the program configuration files. Example:

[program:apache]
command=apache2ctl -c "ErrorLog /dev/stdout" -DFOREGROUND
# this would autostart apache
autostart=true
# this would autorestart it if it crashes
autorestart=true
startretries=1
startsecs=1
redirect_stderr=true
stderr_logfile=/var/log/myapache.err.log
stdout_logfile=/var/log/myapache.out.log
user=root
killasgroup=true
stopasgroup=true

Upvotes: 1

Related Questions