废话不多说:
vi /usr/lib/systemd/system/media-auth.service
[Unit] Description=media-auth server daemon Documentation=no After=no Wants=no [Service] EnvironmentFile=no ExecStart=/usr/bin/node /root/MediaAuth/index.js ExecReload=/bin/kill -HUP $MAINPID ExecStop=/bin/kill -9 $MAINPID KillMode=process Restart=on-failure RestartSec=1s [Install] WantedBy=multi-user.target
启动:
// 开机启动 systemctl enable media-auth.service // 启动 systemctl start media-auth.service
测试一下,正常,启动停止!!!
kill -9 {进程id}
杀后,正常启动..
完美!