CentOS7中Java应用配置成服务

/usr/lib/systemd/system/server_name.service
[Unit]
Description=This is a service.
After=network.target

[Service]
Type=forking
User=root
# 服务主目录
WorkingDirectory=/usr/local/server_name
Restart=on-failure
# 重启间隔,服务异常退出后,等待多少秒再启动
RestartSec=30s
# 限制启动间隔,当为0时,表示不限重启次数
StartLimitInterval=0
RestartPreventExitStatus=SIGKILL
ExecStart=/bin/sh 启动命令
ExecStop=/bin/sh 停止命令

[Install]
WantedBy=multi-user.target