Spring Boot Fat Jar Runner: Difference between revisions
Jump to navigation
Jump to search
(Created page with "==Batch Script== <source lang="bat"> @echo off if "%OS%" == "Windows_NT" setlocal EnableExtensions EnableDelayedExpansion set "CKI_OPTION_NAME=%1" rem rem @author Chorke...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 7: | Line 7: | ||
rem | rem | ||
rem @author Chorke | rem @author Chorke Economia<[email protected]> | ||
rem @vendor Chorke | rem @vendor Chorke Economia, Inc. | ||
rem @web chorke.org | rem @web chorke.org | ||
rem @version 1.0.00 | rem @version 1.0.00 | ||
Line 28: | Line 28: | ||
if "%CKI_SOURCE_BTCH%" == "" set "CKI_SOURCE_BTCH=%~dp0%~nx0" | if "%CKI_SOURCE_BTCH%" == "" set "CKI_SOURCE_BTCH=%~dp0%~nx0" | ||
if "%CKI_PARENT_PATH%" == "" set "CKI_PARENT_PATH=%~dp0" | if "%CKI_PARENT_PATH%" == "" set "CKI_PARENT_PATH=%~dp0" | ||
if "%CKI_ASSETS_PATH%" == "" set "CKI_ASSETS_PATH=%USERPROFILE%\.chorke\ | if "%CKI_ASSETS_PATH%" == "" set "CKI_ASSETS_PATH=%USERPROFILE%\.chorke\economia" | ||
if "%CKI_PIDLOG_PATH%" == "" set "CKI_PIDLOG_PATH=%CKI_ASSETS_PATH%\etc\pid\%CKI_SYSTEM_NAME%.pid" | if "%CKI_PIDLOG_PATH%" == "" set "CKI_PIDLOG_PATH=%CKI_ASSETS_PATH%\etc\pid\%CKI_SYSTEM_NAME%.pid" | ||
Line 48: | Line 48: | ||
if not exist "%CKI_HOME%\usr\local\bin\ebis\" mkdir "%CKI_HOME%\usr\local\bin\ebis\" | if not exist "%CKI_HOME%\usr\local\bin\ebis\" mkdir "%CKI_HOME%\usr\local\bin\ebis\" | ||
if "%JCLASS_MAIN%" == "" set "JCLASS_MAIN= | if "%JCLASS_MAIN%" == "" set "JCLASS_MAIN=org.chorke.boot.BootstrapApplication" | ||
set "JCLASS_PATH=%CKI_HOME%\etc\ebis" | set "JCLASS_PATH=%CKI_HOME%\etc\ebis" | ||
set "JCLASS_PATH=%JCLASS_PATH%;%CKI_HOME%\usr\bin\ebis\*" | set "JCLASS_PATH=%JCLASS_PATH%;%CKI_HOME%\usr\bin\ebis\*" | ||
Line 134: | Line 134: | ||
set /p "=%CKI_DAEMON_NAME% is starting, " <nul | set /p "=%CKI_DAEMON_NAME% is starting, " <nul | ||
rem start "" javaw %JAVA_OPTS% -cp %JCLASS_PATH% %JCLASS_MAIN% | rem start "" javaw %JAVA_OPTS% -cp %JCLASS_PATH% %JCLASS_MAIN% | ||
start "" javaw -jar %CKI_HOME%/ | start "" javaw -jar %CKI_HOME%/economia-ebis-fatjar.jar | ||
timeout 5 > NUL | timeout 5 > NUL | ||
echo started | echo started | ||
Line 190: | Line 190: | ||
==Bash Script== | ==Bash Script== | ||
<source lang="bash"> | |||
#!/bin/bash | |||
: ' | |||
@author Chorke Economia<[email protected]> | |||
@vendor Chorke Economia, Inc. | |||
@web chorke.org | |||
@version 1.0.00 | |||
@since 1.0.00 | |||
' | |||
# init bash meta data | |||
init_ebis(){ | |||
CKI_SYSTEM_NAME='ebis' | |||
CKI_DAEMON_NAME='ebisd' | |||
CKI_SYSTEM_PORT='11110' | |||
CKI_SOURCE_BASH="${BASH_SOURCE[0]}" | |||
CKI_ASSETS_PATH="$HOME/.chorke/economia" | |||
CKI_PROCES_FILE="$CKI_ASSETS_PATH/etc/pid/$CKI_SYSTEM_NAME.pid" | |||
while [ -h "$CKI_SOURCE_BASH" ]; do | |||
CKI_TARGET_BASH="$(readlink "$CKI_SOURCE_BASH")" | |||
if [[ $CKI_TARGET_BASH == /* ]]; then | |||
CKI_SOURCE_BASH="$CKI_TARGET_BASH" | |||
else | |||
CKI_TARGET_PATH="$( dirname "$CKI_SOURCE_BASH" )" | |||
CKI_SOURCE_BASH="$CKI_TARGET_PATH/$CKI_TARGET_BASH" | |||
fi | |||
done | |||
CKI_PARENT_PATH="$( dirname "$CKI_SOURCE_BASH" )" | |||
CKI_TARGET_PATH="$( cd -P "$( dirname "$CKI_SOURCE_BASH" )" && pwd )" | |||
if [ -z "$CKI_HOME" ];then | |||
#CKI_HOME=`cd $CKI_PARENT_PATH/..;pwd` | |||
CKI_HOME=`cd $CKI_PARENT_PATH;pwd` | |||
export CKI_HOME | |||
fi | |||
if [ -z "$HAPI_HOME" ];then | |||
HAPI_HOME=$CKI_ASSETS_PATH/var/$CKI_SYSTEM_NAME/hapi | |||
mkdir -p $HAPI_HOME | |||
export HAPI_HOME | |||
fi | |||
JCLASS_MAIN='org.chorke.boot.BootstrapApplication' | |||
JCLASS_PATH="$CKI_HOME/etc/ebis" | |||
JCLASS_PATH="$JCLASS_PATH:$CKI_HOME/usr/bin/ebis/*" | |||
JCLASS_PATH="$JCLASS_PATH:$CKI_HOME/lib/ebis/pro/ebis/*" | |||
JCLASS_PATH="$JCLASS_PATH:$CKI_HOME/lib/ebis/gpl/*" | |||
JCLASS_PATH="$JCLASS_PATH:$CKI_HOME/lib/ebis/pro/comn/*" | |||
JCLASS_PATH="$JCLASS_PATH:$CKI_HOME/lib/ebis/pro/ecma/*" | |||
} | |||
# fetch the process info | |||
init_meta(){ | |||
CKI_SYSTEM_STAT='stopped' | |||
if [ -f "$CKI_PROCES_FILE" ];then | |||
CKI_SYSTEM_PIDV=`cat $CKI_PROCES_FILE` | |||
if ps -p $CKI_SYSTEM_PIDV > /dev/null 2>&1;then | |||
CKI_SYSTEM_STAT='running' | |||
fi | |||
fi | |||
} | |||
# init java option for jmx | |||
init_opts(){ | |||
JAVA_OPTS='-Xmx512M -XX:MaxPermSize=512M -XX:+CRMSlassUnloadingEnabled' | |||
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote" | |||
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=$CKI_SYSTEM_PORT" | |||
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false" | |||
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false" | |||
JAVA_OPTS="$JAVA_OPTS -Duser.home=$HOME" | |||
JAVA_OPTS="$JAVA_OPTS -Duser.name=$USER" | |||
} | |||
# init system config | |||
init_full(){ | |||
if [ "$CKI_ACTION_INIT" != "true" ];then | |||
init_ebis | |||
fi | |||
init_meta | |||
init_opts | |||
} | |||
# inti full/entrie process | |||
init_full | |||
</source> |
Latest revision as of 21:46, 20 November 2019
Batch Script
@echo off
if "%OS%" == "Windows_NT" setlocal EnableExtensions EnableDelayedExpansion
set "CKI_OPTION_NAME=%1"
rem
rem @author Chorke Economia<[email protected]>
rem @vendor Chorke Economia, Inc.
rem @web chorke.org
rem @version 1.0.00
rem @since 1.0.00
rem
call :init_ebis
call :init_opts
call :ebis_case
goto :eof
:init_ebis
rem initialization of varible
if "%CKI_SYSTEM_NAME%" == "" set "CKI_SYSTEM_NAME=ebis"
if "%CKI_DAEMON_NAME%" == "" set "CKI_DAEMON_NAME=ebisd"
if "%CKI_SYSTEM_PORT%" == "" set "CKI_SYSTEM_PORT=11190"
if "%CKI_SOURCE_BTCH%" == "" set "CKI_SOURCE_BTCH=%~dp0%~nx0"
if "%CKI_PARENT_PATH%" == "" set "CKI_PARENT_PATH=%~dp0"
if "%CKI_ASSETS_PATH%" == "" set "CKI_ASSETS_PATH=%USERPROFILE%\.chorke\economia"
if "%CKI_PIDLOG_PATH%" == "" set "CKI_PIDLOG_PATH=%CKI_ASSETS_PATH%\etc\pid\%CKI_SYSTEM_NAME%.pid"
rem user and user home
if "%USER%" == "" set "USER=%USERNAME%"
if "%HOME%" == "" set "HOME=%USERPROFILE%"
if "%HAPI_HOME%" == "" set "HAPI_HOME=%CKI_ASSETS_PATH%\var\%CKI_SYSTEM_NAME%\hapi"
rem program/deamon home
rem if "%CKI_HOME%" == "" set "CKI_HOME=%CKI_PARENT_PATH%.."
if "%CKI_HOME%" == "" set "CKI_HOME=%CKI_PARENT_PATH%"
pushd "%CKI_HOME%"
set "CKI_HOME=%CD%"
echo "%CKI_HOME%"
rem create swap gpl dir
if not exist "%CKI_HOME%\usr\local\bin\ebis\" mkdir "%CKI_HOME%\usr\local\bin\ebis\"
if "%JCLASS_MAIN%" == "" set "JCLASS_MAIN=org.chorke.boot.BootstrapApplication"
set "JCLASS_PATH=%CKI_HOME%\etc\ebis"
set "JCLASS_PATH=%JCLASS_PATH%;%CKI_HOME%\usr\bin\ebis\*"
set "JCLASS_PATH=%JCLASS_PATH%;%CKI_HOME%\lib\ebis\pro\ebis\*"
set "JCLASS_PATH=%JCLASS_PATH%;%CKI_HOME%\lib\ebis\gpl\*"
set "JCLASS_PATH=%JCLASS_PATH%;%CKI_HOME%\lib\ebis\pro\comn\*"
set "JCLASS_PATH=%JCLASS_PATH%;%CKI_HOME%\lib\ebis\pro\ecma\*"
goto :eof
rem fetch the process info
:init_meta
rem fetch pid
if exist "%CKI_PIDLOG_PATH%" set /p CKI_SYSTEM_PIDV=<"%CKI_PIDLOG_PATH%"
rem check pid
set "CKI_SYSTEM_STAT=stopped"
tasklist /fi "pid eq %CKI_SYSTEM_PIDV%" |findstr /c:"%CKI_SYSTEM_PIDV%">nul && (set "CKI_SYSTEM_STAT=running") || (set "CKI_SYSTEM_STAT=stopped")
goto :eof
:init_opts
rem init java option for jmx
set "JAVA_OPTS=-Xmx512M -XX:MaxPermSize=512M -XX:+CRMSlassUnloadingEnabled"
set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote"
set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=%CKI_SYSTEM_PORT%"
set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.authenticate=false"
set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.ssl=false"
set "JAVA_OPTS=%JAVA_OPTS% -Duser.home=%HOME%"
set "JAVA_OPTS=%JAVA_OPTS% -Duser.name=%USER%"
goto :eof
:ebis_case
rem label ebis_case
call :init_meta
set "CKI_SWITCH_CASE=false"
for %%i in (start stop status restart) do (
if %%i'==%CKI_OPTION_NAME%' SET "CKI_SWITCH_CASE=true"
)
if "%CKI_SWITCH_CASE%" == "false" call :case_error
if "%CKI_SWITCH_CASE%" == "true" call :case_%CKI_OPTION_NAME%
goto :eof
:case_start
rem label case_start
call :start
goto :eof
:case_stop
rem label case_stop
call :stop
goto :eof
:case_status
rem label case_status
call :status
goto :eof
:case_restart
rem label case_restart
call :restart
goto :eof
:restart
rem label restart
call :stop
call :start
goto :eof
:start
rem label start
if "%CKI_SYSTEM_STAT%" == "running" (
echo %CKI_DAEMON_NAME% already %CKI_SYSTEM_STAT%
)
if "%CKI_SYSTEM_STAT%" == "stopped" (
set /p "=%CKI_DAEMON_NAME% is starting, " <nul
rem start "" javaw %JAVA_OPTS% -cp %JCLASS_PATH% %JCLASS_MAIN%
start "" javaw -jar %CKI_HOME%/economia-ebis-fatjar.jar
timeout 5 > NUL
echo started
)
goto :eof
:status
rem label status
echo %CKI_DAEMON_NAME% is %CKI_SYSTEM_STAT%
goto :eof
rem label stop
:stop
if "%CKI_SYSTEM_STAT%" == "stopped" (
echo %CKI_DAEMON_NAME% already %CKI_SYSTEM_STAT%
)
if "%CKI_SYSTEM_STAT%" == "running" (
call :init_meta
set /p "=%CKI_DAEMON_NAME% is stopping, " <nul
taskkill /F /PID %CKI_SYSTEM_PIDV% 1>NUL
for /L %%a in (0,1,10) do (
if %%a lss 10 (
if "!CKI_SYSTEM_STAT!" == "running" (
timeout 3 > NUL
call :init_meta
)
if "!CKI_SYSTEM_STAT!" == "stopped" (
echo stopped
goto :eof
)
)
if %%a equ 10 (
echo unable to stop
)
)
)
goto :eof
rem label case_error
:case_error
echo Usage^: start^|stop^|^status^|restart
goto :eof
:case_pause
rem label case_pause
@pause
goto :eof
Bash Script
#!/bin/bash
: '
@author Chorke Economia<[email protected]>
@vendor Chorke Economia, Inc.
@web chorke.org
@version 1.0.00
@since 1.0.00
'
# init bash meta data
init_ebis(){
CKI_SYSTEM_NAME='ebis'
CKI_DAEMON_NAME='ebisd'
CKI_SYSTEM_PORT='11110'
CKI_SOURCE_BASH="${BASH_SOURCE[0]}"
CKI_ASSETS_PATH="$HOME/.chorke/economia"
CKI_PROCES_FILE="$CKI_ASSETS_PATH/etc/pid/$CKI_SYSTEM_NAME.pid"
while [ -h "$CKI_SOURCE_BASH" ]; do
CKI_TARGET_BASH="$(readlink "$CKI_SOURCE_BASH")"
if [[ $CKI_TARGET_BASH == /* ]]; then
CKI_SOURCE_BASH="$CKI_TARGET_BASH"
else
CKI_TARGET_PATH="$( dirname "$CKI_SOURCE_BASH" )"
CKI_SOURCE_BASH="$CKI_TARGET_PATH/$CKI_TARGET_BASH"
fi
done
CKI_PARENT_PATH="$( dirname "$CKI_SOURCE_BASH" )"
CKI_TARGET_PATH="$( cd -P "$( dirname "$CKI_SOURCE_BASH" )" && pwd )"
if [ -z "$CKI_HOME" ];then
#CKI_HOME=`cd $CKI_PARENT_PATH/..;pwd`
CKI_HOME=`cd $CKI_PARENT_PATH;pwd`
export CKI_HOME
fi
if [ -z "$HAPI_HOME" ];then
HAPI_HOME=$CKI_ASSETS_PATH/var/$CKI_SYSTEM_NAME/hapi
mkdir -p $HAPI_HOME
export HAPI_HOME
fi
JCLASS_MAIN='org.chorke.boot.BootstrapApplication'
JCLASS_PATH="$CKI_HOME/etc/ebis"
JCLASS_PATH="$JCLASS_PATH:$CKI_HOME/usr/bin/ebis/*"
JCLASS_PATH="$JCLASS_PATH:$CKI_HOME/lib/ebis/pro/ebis/*"
JCLASS_PATH="$JCLASS_PATH:$CKI_HOME/lib/ebis/gpl/*"
JCLASS_PATH="$JCLASS_PATH:$CKI_HOME/lib/ebis/pro/comn/*"
JCLASS_PATH="$JCLASS_PATH:$CKI_HOME/lib/ebis/pro/ecma/*"
}
# fetch the process info
init_meta(){
CKI_SYSTEM_STAT='stopped'
if [ -f "$CKI_PROCES_FILE" ];then
CKI_SYSTEM_PIDV=`cat $CKI_PROCES_FILE`
if ps -p $CKI_SYSTEM_PIDV > /dev/null 2>&1;then
CKI_SYSTEM_STAT='running'
fi
fi
}
# init java option for jmx
init_opts(){
JAVA_OPTS='-Xmx512M -XX:MaxPermSize=512M -XX:+CRMSlassUnloadingEnabled'
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=$CKI_SYSTEM_PORT"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTS="$JAVA_OPTS -Duser.home=$HOME"
JAVA_OPTS="$JAVA_OPTS -Duser.name=$USER"
}
# init system config
init_full(){
if [ "$CKI_ACTION_INIT" != "true" ];then
init_ebis
fi
init_meta
init_opts
}
# inti full/entrie process
init_full