一个node项目的demo

# the puppeteer of node service
[Unit]
Description=puppeteer

[Service]
TimeoutStartSec=180
TimeoutStopSec=30
# restart
# Restart=always
# RuntimeMaxSec=10800
# RuntimeMaxSec=30
# RestartSec=30
# exec
ExecStart=/usr/local/bin/node /home/xxx/xxxx/xxx/xxx/node/bbs/bin/www
ExecStop=/usr/bin/pkill node
# log
StandardOutput=syslog
StandardError=syslog

然后利用crontab定期重启即可。

那么简单定义一下我们的java程序jar

# 19999端口
[Unit]
Description=domaincheck

[Service]
TimeoutStartSec=100
TimeoutStopSec=30
ExecStart=/bin/java -Dserver.tomcat.basedir=. -Dserver.tomcat.accesslog.enabled=true -Dserver.port=19999 -jar -Dspring.redis.timeout=30000 /xxxxxx/p19876/xxxxx-0.0.1-SNAPSHOT.jar
# ExecStop=/usr/bin/pkill