Linux系统进程守护systemd
创建文件(下面web为名称自行修改)
vi /usr/lib/systemd/system/web.service
添加参数(以下参数web为路径自行修改)
\[Unit\]
Description=web
After=network.target
\[Service\]
Type=simple
WorkingDirectory=web //工作目录
ExecStart=web/node app.js //前面路径,后面启动命令
#User=root //应用程序运行的用户名(默认root,已注释)
Restart=on-failure //失败自动重启
\[Install\]
WantedBy=multi-user.target
启动参数
重载配置: systemctl daemon-reload
启动: systemctl start web
关闭: systemctl stop web
配置开机自启: systemctl enable web
取消开机自启: systemctl disable web
状态: systemctl status web
重启: systemctl restart web
评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果