管理 Supervisord 进程 - 在 boot/Auto 崩溃时自动启动
Manage Supervisord process - Auto start on boot/Auto start upon it crash
我们正在使用 Supervisord 进行 apache 服务器进程监控。
所以我想让主管进程在以下两种情况下始终运行:
- 服务器重新启动时自动启动主管(没有 init.d 帮助)
- 在 运行.
时自动启动主管进程崩溃
我们也安装了ansible。
如果有人能分享他们的想法就太好了。
我将从 ansible 开始——你可以用它来安装 supervisor(以 apt 模块为例,如果必须的话使用 yum module):
- name: Install Supervisord
apt: name=supervisor state=present update_cache=yes
become: yes
并部署必要的主管配置文件(使用 copy module)。
- name: Deploy config file
copy: src=yourconfigfile.conf dest=/etc/supervisor/conf.d/apache.conf mode=644
become: yes
要自动启动主管本身,您只需启用它(您可以使用 service module - 启用:是)。要让管理员控制程序自动启动和自动重启,请在程序配置文件中设置正确的指令。示例:
[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
我们正在使用 Supervisord 进行 apache 服务器进程监控。
所以我想让主管进程在以下两种情况下始终运行:
- 服务器重新启动时自动启动主管(没有 init.d 帮助)
- 在 运行. 时自动启动主管进程崩溃
我们也安装了ansible。
如果有人能分享他们的想法就太好了。
我将从 ansible 开始——你可以用它来安装 supervisor(以 apt 模块为例,如果必须的话使用 yum module):
- name: Install Supervisord
apt: name=supervisor state=present update_cache=yes
become: yes
并部署必要的主管配置文件(使用 copy module)。
- name: Deploy config file
copy: src=yourconfigfile.conf dest=/etc/supervisor/conf.d/apache.conf mode=644
become: yes
要自动启动主管本身,您只需启用它(您可以使用 service module - 启用:是)。要让管理员控制程序自动启动和自动重启,请在程序配置文件中设置正确的指令。示例:
[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