守护进程

本文于 1921 天之前发表,文中内容可能已经过时。

守护进程使用supervisor,一直用的都是这个东西

1
2
3
4
5
6
7
yum list | grep supervisor

不存在的话,添加一下
wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm

yum install supervisor

增加自定义的配置信息 有的版本include无效,最好直接写到配置文件中

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
vim /etc/supervisor/supervisord.conf

[include]
files = /etc/supervisor/config.d/*.ini

mkdir /etc/supervisor/config.d

vim /etc/supervisor/config.d/hexo.ini

[program:hexo]
command=/home/www/b_hexo/node_modules/hexo/bin/hexo generate --watch
autostart=true
autorestart=true
user=root
numprocs=3
stdout_logfile=/var/log/supervisor-hexo.log

启动和查看

1
2
3
4
5
6
7
supervisord -c /etc/supervisor/supervisord.conf

查看进程
ps -aux | grep hexo

supervisorctl status
supervisorctl reload

1
2
3
int main(){
return main();
}