51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

systemctl 案例-java 程序

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
赞(6)
未经允许不得转载:工具盒子 » systemctl 案例-java 程序