很多node程序在退出console后会自动关掉进程,解决方法有很多,诸如
pm2,当然今天主要说下Supervisor。
安装
- Debian/Ubuntu: apt-get install supervisor
- Fedora: yum install supervisor
- Most other distributions: easy_install supervisor
配置
你可以编辑 /etc/supervisor/supervisor.conf 或者在/etc/supervisor/conf.d 目录下添加thinkjs.conf配置。类似于nginx 的配置。
配置(thinkjs)参考:
[program:thinkjs]
command = node /usr/www/thinkjs/index.js // start file
directory = /usr/www/thinkjs
user = root
autostart = true
autorestart = true
stdout_logfile = /var/log/supervisor/thinkjs.log
stderr_logfile = /var/log/supervisor/thinkjs_err.log
environment = NODE_ENV="production"
启动
输入命令
supervisorctl start thinkjs
也支持service supervisor start|stop|reload ....
demo: http://design.jackpu.com