Score
0
Watch 112 Star 304 Fork 108

隐心 / lightosJavaAGPL-3.0

Join us
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
lightos = Light OS , 轻系统/光速系统,基于SpringBoot打造的一套集开发与运维为一体的辅助系统。 spread retract

https://github.com/214175590/lightos

  • JavaScript 60.7%
  • CSS 17.3%
  • Java 16.8%
  • HTML 3.8%
  • TypeScript 1.3%
  • Other 0.1%
Clone or download
lightos.sh 2.34 KB
Copy Edit Web IDE Raw Blame History
隐心 authored 2018-11-19 11:32 . 代码提交
#!/bin/sh
#
APP_HOME=~/bin
#启动的程序名称
APP_NAME=lightos
PROFILE=dev,swagger
LOG_PATH=~/bin/logs
LOG_FILE=lightos
#java虚拟机启动参数
JAVA_OPTS="-Xmx1048m -Xms512m"
#**************************
#(函数)判断程序是否已启动
#初始化psid变量
#****************************
psid=0
checkpid() {
JPID=$(ps -ef | grep java.*$APP_NAME.*.war | grep -v grep | awk '{ print $2 }')
if [ -z "$JPID" ]
then
psid=0
else
psid=$JPID
fi
}
#**************************
#启动程序
#****************************
start() {
checkpid
if [ $psid -ne 0 ]; then
echo "================================"
echo "warn: $APP_NAME already started! (pid=$psid)"
echo "================================"
else
echo -n "Starting $APP_NAME ..."
nohup java -jar $APP_HOME/$APP_NAME*.war $JAVA_OPTS --spring.profiles.active=$PROFILE >/dev/null 2>&1 &
checkpid
if [ $psid -ne 0 ]; then
echo "(pid=$psid) [OK]"
else
echo "[Failed]"
fi
fi
}
#*****************************
#停止程序
#*****************************
stop() {
checkpid
if [ $psid -ne 0 ]; then
echo -n "Stopping $APP_NAME ...(pid=$psid) "
kill $psid
if [ $? -eq 0 ]; then
echo "[OK]"
else
echo "[Failed]"
fi
checkpid
if [ $psid -ne 0 ]; then
kill -9 $psid
else
echo "[force stop OK]"
fi
checkpid
if [ $psid -ne 0 ]; then
stop
fi
else
echo "================================"
echo "warn: $APP_NAME is not running"
echo "================================"
fi
}
#****************************
#检查程序运行状态
#****************************
status() {
checkpid
if [ $psid -ne 0 ]; then
echo "$APP_NAME is running! (pid=$psid)"
else
echo "$APP_NAME is not running"
fi
}
#********************************
#读取脚本的第一个参数($1),进行判断
#参数取值范围:{start|stop|restart|status}
###################################
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
'status')
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0

Comment ( 0 )

Sign in for post a comment

Java
1
https://gitee.com/yisin/lightos.git
git@gitee.com:yisin/lightos.git
yisin
lightos
lightos
master

Help Search