linux启动java进程的shell脚本(包括启动,停止,重启)
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
近来使用spring boot写了一个短信服务组件,并配上此段脚本,实现对服务进程的管理
#!/bin/bash
# chkconfig: 2345 85 85
# description: sms-service is a micro-service component for lige short message service
# processname: sms-service
# Created By: zhangle (zhanngle@gmail.com)
PROG=sms-service
PIDFILE=/data/sms-service/smss.pid
JAVA_HOME=/data/jdk1.8.0_45
status() {
if [ -f $PIDFILE ]; then
PID=$(cat $PIDFILE)
if [ ! -x /proc/${PID} ]; then
return 1
else
return 0
fi
else
return 1
fi
}
case "$1" in
start)
status
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "$PIDFILE exists, process is already running or crashed"
exit 1
fi
echo "Starting $PROG ..."
$JAVA_HOME/bin/java -server -Xms512m -Xmx512m -jar sms-service.jar &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "$PROG is started"
echo $! > $PIDFILE
exit 0
else
echo "Stopping $PROG"
rm -f $PIDFILE
exit 1
fi
;;
stop)
status
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "Shutting down $PROG"
kill `cat $PIDFILE`
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
rm -f $PIDFILE
else
echo "Failed to stopping $PROG"
fi
fi
;;
status)
status
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
PID=$(cat $PIDFILE)
echo "$PROG is running ($PID)"
else
echo "$PROG is not running"
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
;;
esac
GitHub 加速计划 / li / linux-dash
6
1
下载
A beautiful web dashboard for Linux
最近提交(Master分支:3 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献2条内容
所有评论(0)