huixisheng / huixisheng.github.com

前端开发者说,记录前端的故事
http://huixisheng.github.io/
12 stars 3 forks source link

Nodejs自启动,守护进程 #73

Open huixisheng opened 5 years ago

huixisheng commented 5 years ago

进程管理器

pm2 https://github.com/Unitech/pm2

forever https://github.com/foreverjs/forever

自带命令nohup

后台运行进程

Nodejs调试

nodemon

Monitor for any changes in your node.js application and automatically restart the server - perfect for development

supervisor https://github.com/petruisfan/node-supervisor/

开机启动

CentOS 7

/etc/rc.d/rc.local文件的权限被降低了。需要执行chmod +x /etc/rc.d/rc.local。软链接/etc/rc.local

#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
cd /root/huixisheng/node-servers/j-excel/ && forever index.js

MacOSX 开机启动 | 前端开发者说

综合