CentOS7的服务systemctl脚本存放在:/usr/lib/systemd/,有系统(system)和用户(user)之分,
每一个服务以.service结尾,一般会分为3部分:[Unit]、[Service]和[Install],具体内容如下:
[Unit]
Description=xiyoulibapi
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/node.js/pid
ExecStart=/usr/local/bin/forever start /node.js/xiyoulib/bin/www
ExecReload=/usr/local/bin/forever restart /node.js/xiyoulib/bin/www
ExecStop=/usr/local/bin/forever stop /node.js/xiyoulib/bin/www
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[Unit]
Description=myapp service
After=syslog.target
[Service]
Type=simple
ExecStart=/usr/bin/java -Xms1024m -Xmx1024m -DSERVICE_LOG_FOLDER=/data/logs -jar /usr/local/software/myapp/myapp.jar --spring.config.location=/usr/local/software/myapp/bootstrap.yml
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
原文:https://www.cnblogs.com/lenovo_tiger_love/p/10096889.html