is_exist(){ pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}'` # if progress is exist then return 1,else return 0 if [ -z "${pid}" ]; then return 1 else return 0 fi }
start(){ is_exist if [ $? -eq 0 ]; then echo"${APP_NAME} is already running. pid=${pid}" else nohup java ${JVM} -jar ./${APP_NAME}${ARGS} > ${LOG_FILE} 2>&1 & echo"${APP_NAME} is start successfully, use 'log' option to print more info." fi }
stop(){ is_exist if [ $? -eq "0" ]; then kill -9 $pid echo"${APP_NAME} is stoped" else echo"${APP_NAME} is not running" fi }
status(){ is_exist if [ $? -eq "0" ]; then echo"${APP_NAME} is running. Pid is ${pid}" else echo"${APP_NAME} is NOT running." fi }
restart(){ stop sleep 2 start }
log(){ tail -n 100 -f server.log }
case"$1"in "start") start ;; "stop") stop ;; "status") status ;; "restart") restart ;; "log") log ;; *) help ;; esac
set app_name=myapp set jvm="-Dfile.encoding=utf-8" -server -Xmx1g set args=--spring.profiles.active=dev --server.port=8080 set log_file=running.log
@echo on javaw.exe %jvm% -jar %app_name%.jar %args% > %log_file%2>&1 & @echo off
echo. echo The Service is running in background...
echo. echo This script will exit.
ping localhost -n 4 >nul echo Press any key to exit. @REM exit
@REM You can use command 'jps' or 'netstat -ano |findstr programPort' to check your application. @REM Run command 'taskkill /f /t /im jeecg.exe' to kill the process.