命令修改

This commit is contained in:
jiangzeyin 2019-04-12 18:11:02 +08:00
parent b8efd4ba72
commit 7a3e7a8ee1
2 changed files with 72 additions and 50 deletions

View File

@ -1,6 +1,6 @@
@REM The MIT License (MIT)
@REM
@REM Copyright (c) 2019 码之科技工作室
@REM Copyright (c) 2019 码之科技工作室
@REM
@REM Permission is hereby granted, free of charge, to any person obtaining a copy of
@REM this software and associated documentation files (the "Software"), to deal in
@ -23,67 +23,85 @@
@echo off
setlocal enabledelayedexpansion
set Tag=KeepBx-System-JpomApplication1
set Tag=KeepBx-System-JpomApplication
set MainClass=cn.keepbx.jpom.JpomApplication
set CloseMainClass=cn.keepbx.jpom.JpomClose
set basePath=%~dp0
set Lib=%basePath%lib\
set Log=%basePath%run.log
set LogBack=%basePath%log\
set JVM=-server
set ARGS= --jpom.applicationTag=%Tag% --jpom.log=%basePath%log --server.port=2122
if "%1"=="start" (
call:start
)else (
if "%1"=="stop" (
call:stop
)else (
if "%1"=="restart" (
call:restart
)else (
if "%1"=="status" (
call:status
)else (
call:use
)
)
)
)
pause
color 0a
TITLE Jpom管理系统BAT控制台
echo. ***** Jpom管理系统BAT控制台 *****
::*************************************************************************************************************
echo.
echo. [1] 启动 start
echo. [2] 关闭 stop
echo. [3] 查看运行状态 status
echo. [4] 重启 restart
echo. [5] 帮助 use
echo. [0] 退 出 0
echo.
@REM 启动
echo.请输入选择的序号:
set /p ID=
IF "%id%"=="1" goto start
IF "%id%"=="2" goto stop
IF "%id%"=="3" goto status
IF "%id%"=="4" goto restart
IF "%id%"=="5" goto use
IF "%id%"=="0" EXIT
PAUSE
echo 即将关闭窗口
timeout 3
EXIT 1
@REM 启动
:start
set TEMPCLASSPATH=
for /f "delims=" %%I in ('dir /B %Lib%') do (set TEMPCLASSPATH=!TEMPCLASSPATH!%Lib%%%I;)
@REM echo 启动成功,关闭窗口不影响运行
cmd /S /C "javaw %JVM% -classpath %TEMPCLASSPATH%"%JAVA_HOME%"\lib\tools.jar -Dapplication=%Tag% -Dbasedir=%basePath% %MainClass% %ARGS% >> %Log%"
echo 启动中.....
rem 备份日志
if exist %Log% (
if not exist %LogBack% (
echo %LogBack%
md %LogBack%
)
move %Log% %LogBack%%date:~0,4%%date:~5,2%%date:~8,2%0%time:~1,1%%time:~3,2%%time:~6,2%.log
del %Log%
)
set TEMPCLASSPATH=
for /f "delims=" %%I in ('dir /B %Lib%') do (set TEMPCLASSPATH=!TEMPCLASSPATH!%Lib%%%I;)
REM echo 启动成功,关闭窗口不影响运行
echo 启动中.....关闭窗口不影响运行
javaw %JVM% -classpath %TEMPCLASSPATH%"%JAVA_HOME%"\lib\tools.jar -Dapplication=%Tag% -Dbasedir=%basePath% %MainClass% %ARGS% >> %Log%
timeout 3
goto:eof
@REM 关闭Jpom
@REM 关闭Jpom
:stop
set TEMPCLASSPATH=
for /f "delims=" %%I in ('dir /B %Lib%') do (set TEMPCLASSPATH=!TEMPCLASSPATH!%Lib%%%I;)
set MainClass=cn.keepbx.jpom.JpomClose
set ARGS= --jpom.applicationTag=%Tag% --event=stop
java -classpath %TEMPCLASSPATH%"%JAVA_HOME%"\lib\tools.jar %MainClass% %ARGS%
set TEMPCLASSPATH=
for /f "delims=" %%I in ('dir /B %Lib%') do (set TEMPCLASSPATH=!TEMPCLASSPATH!%Lib%%%I;)
java -classpath %TEMPCLASSPATH%"%JAVA_HOME%"\lib\tools.jar %CloseMainClass% %ARGS% --jpom.applicationTag=%Tag% --event=stop
goto:eof
@REM 查看Jpom运行状态
@REM 查看Jpom运行状态
:status
set TEMPCLASSPATH=
for /f "delims=" %%I in ('dir /B %Lib%') do (set TEMPCLASSPATH=!TEMPCLASSPATH!%Lib%%%I;)
set MainClass=cn.keepbx.jpom.JpomClose
set ARGS= --jpom.applicationTag=%Tag% --event=status
java -classpath %TEMPCLASSPATH%"%JAVA_HOME%"\lib\tools.jar %MainClass% %ARGS%
set TEMPCLASSPATH=
for /f "delims=" %%I in ('dir /B %Lib%') do (set TEMPCLASSPATH=!TEMPCLASSPATH!%Lib%%%I;)
java -classpath %TEMPCLASSPATH%"%JAVA_HOME%"\lib\tools.jar %CloseMainClass% %ARGS% --jpom.applicationTag=%Tag% --event=status
goto:eof
@REM 重启Jpom
@REM 重启Jpom
:restart
call:stop
call:start
echo 停止中....
call:stop
timeout 3
echo 启动中....
call:start
goto:eof
@REM 提示用法
@REM 提示用法
:use
echo please use (start|stop|restart|status)
echo please use (start|stop|restart|status)
goto:eof

View File

@ -42,11 +42,12 @@ function start() {
if [[ ! -d ${LogBack} ]];then
mkdir ${LogBack}
fi
cur_dateTime="`date +%Y-%m-%d_%H:%M:%S`.log"
mv ${Log} ${LogBack}${cur_dateTime}
echo "mv to $LogBack$cur_dateTime"
touch ${Log}
cur_dateTime="`date +%Y-%m-%d_%H:%M:%S`.log"
mv ${Log} ${LogBack}${cur_dateTime}
echo "mv to $LogBack$cur_dateTime"
fi
# 创建文件
touch ${Log}
# classPath
CLASSPATH=`listDir ${Lib}`
nohup java ${JVM} -classpath ${CLASSPATH}${JAVA_HOME}/lib/tools.jar -Dapplication=${Tag} -Dbasedir=${Path} ${MainClass} ${ARGS} >> ${Log} 2>&1 &
@ -105,6 +106,12 @@ function usage()
RETVAL="2"
}
# 判断环境变量
if [[ -z "${JAVA_HOME}" ]] ; then
echo "请配置 【JAVA_HOME】 环境变量"
exit "0"
fi
# See how we were called.
RETVAL="0"
case "$1" in
@ -118,9 +125,6 @@ case "$1" in
stop
start
;;
reload)
RETVAL="3"
;;
status)
status
;;