[Unit]
Description=jar server
After=network.target,network.service #start this service after network.target and network.service
Before= #start this service before some other services
Requires=network.service #shutdown if the network.service is down.
[Service]
WorkingDirectory=/home/***/
Type=forking
ExecStart=/home/***/start-jar.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -9 $MAINPID
PrivateTmp=true
Restart=always
RestartSec=15
StartLimitInterval=0
StartLimitBurst=5
[Install]
WantedBy=multi-user.target
for multi-threads programmes:
[Unit]
Description=n server
After=network.target
[Service]
WorkingDirectory=/home/***/
Type=forking
ExecStart=/home/***/n
ExecReload=/home/***/n -s reload
ExecStop=/bin/killall n
PrivateTmp=true
Restart=always
RestartSec=10
StartLimitInterval=0
StartLimitBurst=5
[Install]
WantedBy=multi-user.target