[Unit]
Description="My Express App"
[Service]
ExecStart=/usr/bin/node server.js
WorkingDirectory=/project/absolute/path
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=MyApp
Environment=NODE_ENV=production PORT=8080
[Install]
WantedBy=multi-user.target
/etc/systemd/system/my-app.service
文件中,然后使用systemctl
启动它。systemctl enable my-app.service
systemctl start my-app.service
现在假设你的Linux发行版使用systemctl。如果你的Linux发行版使用upstart或其他什么东西,那么你需要谷歌该进程管理器的指令。