Home > OS >  Great god help me trouble will rewrite the following sh file into a bat file, thanks
Great god help me trouble will rewrite the following sh file into a bat file, thanks

Time:09-21

 #! The/usr/bin/env bash 

INPUT=$2
Configured FILE_PATH=` readlink - f ${} `
SERVICE=${INPUT# # */}
The SERVICE_NAME=${SERVICE %. *}
DEPLOY_DIR=` PWD `
JVM_OPTS="- server - Xms64m - Xmx128m"

If the [[" $1 "=" "]].
Then
Echo - e "\ [0; 31 m not input operation 033\033 [0 m \ [0; 34 m 033 {start | stop | restart | status} \ 033 [0 m
"The exit 1
Fi

If the [[$SERVICE ""=" "]].
Then
Echo - e "\ [0; 31 m not input application 033\033 [0 m
"The exit 1
Fi

LOGS_DIR="$DEPLOY_DIR/logs/$SERVICE_NAME"
Echo "$LOGS_DIR
"If the [[! - d "$LOGS_DIR"]]. Then
The mkdir -p ${LOGS_DIR}
Fi

LOG_PATH="$LOGS_DIR/stdout. Out"
Pid=0

Start ()
{
CheckPid
If the [[! - n "$pid"]]. Then
BUILD_ID=dontKillMe nohup Java $${FILE_PATH} {JVM_OPTS} - jar & gt;> The ${LOG_PATH} 2 & gt; & 1 & amp;
Echo "$SERVICE_NAME is starting, you can check the $LOG_PATH"
The else
Echo "$SERVICE_NAME is running PID: $PID"
Fi
}

CheckPid ()
{
Pid=` ps - ef | grep ${FILE_PATH} | grep -v grep | awk '{print $2}' `
}

Stop ()
{
CheckPid
If the [[! - n "$pid"]]. Then
Echo "$SERVICE_NAME not running"
The else
Echo "$SERVICE_NAME stop... "
Kill 9 ${pid}
Fi
}

Restart ()
{
Stop
Sleep 2
Start
}

The status ()
{
CheckPid
If the [[! - n "$pid"]]. Then
Echo "$SERVICE_NAME not running"
The else
Echo "$SERVICE_NAME running PID: $PID"
Fi
}

In case $1
Start) start;;
Stop stop);;
Restart) restart;;
Status) status;;
*) echo "the require start | stop | restart | status";;
Esac

CodePudding user response:

Who can so carefree, for such a long code,,,