systemctl java
service:
cat /usr/lib/systemd/system/gzm_eres.service
[Unit]
Description=GuangZhou Metro`s Eres service[prod] for java
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/home/liuw/gzm/script/eres/start.sh
ExecStop=/home/liuw/gzm/script/eres/stop.sh
PrivateTmp=true
[Install]
WantedBy=Multi-user.target
cat /home/liuw/gzm/script/eres/start.sh
#!/bin/bash
source /etc/profile
#nohup java -jar -server /home/liuw/gzm/eres-1.0.0-SNAPSHOT.jar > /dev/null &
LOG_HOME=/mnt/vdb/log/gzm/eres
java -Dspring.profiles.active=prod -jar /home/liuw/gzm/eres-service-1.0.0-SNAPSHOT.jar > /dev/null &
echo $! > /var/run/gzm_eres.pid
cat /home/liuw/gzm/script/eres/stop.sh
#!/bin/bash
PID=$(cat /var/run/gzm_eres.pid)
kill -9 $PID