From 36d9a52613128d6a0512e63959621e8068c343ab Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 15 Dec 2023 10:34:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=90=AF=E5=8A=A8=E5=91=BD?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- start.sh | 3 +++ stop.sh | 3 +++ stup.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 start.sh create mode 100644 stop.sh create mode 100644 stup.sh diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..12fa1db --- /dev/null +++ b/start.sh @@ -0,0 +1,3 @@ +./stup.sh start ./output/dfbattle.dll ws://127.0.0.1:9897 +sleep 1 +exit \ No newline at end of file diff --git a/stop.sh b/stop.sh new file mode 100644 index 0000000..933b082 --- /dev/null +++ b/stop.sh @@ -0,0 +1,3 @@ +./stup.sh stop ./output/dfbattle.dll ws://127.0.0.1:9897 +sleep 1 +exit \ No newline at end of file diff --git a/stup.sh b/stup.sh new file mode 100644 index 0000000..1f3cc24 --- /dev/null +++ b/stup.sh @@ -0,0 +1,61 @@ +#!/bin/bash +SERVICE="$2 $3" +CMD="dotnet $2 $3" +CMD2=$2 +CMD3=$3 +start(){ + echo "starting $SERVICE..." + num=`ps -ef | grep dotnet | grep $CMD2 | grep $CMD3 |grep -v grep | grep -v /bin/bash | wc -l` + if [ $num -eq 0 ] + then + # nohup $CMD > /dev/null 2>&1 & + nohup $CMD > s.log 2>&1 & + if [ $? -ne 0 ] + then + echo "start failed, please check the log!" + exit $? + else + + # echo $! > $SERVICE.pid + echo "start success" + fi + else + echo "$SERVICE is already running" + fi + + +} +stop(){ + echo "stopping $SERVICE..." + #kill -9 `cat $SERVICE.pid` + kill -9 `ps -ef | grep dotnet | grep $CMD2 | grep $CMD3 | awk '{print $2}'` + if [ $? -ne 0 ] + then + echo "stop failed, may be $SERVICE isn't running" + exit $? + else + #rm -rf $SERVICE.pid + echo "stop success" + fi +} +restart(){ + stop&&start +} +status(){ + num=`ps -ef | grep dotnet | grep $CMD2 || grep $CMD3 | grep -v grep | wc -l` + if [ $num -eq 0 ] + then + echo "$SERVICE isn't running" + else + echo "$SERVICE is running" + fi +} +case $1 in + start) start ;; + stop) stop ;; + restart) restart ;; + status) status ;; + *) echo "Usage: $0 {start|stop|restart|status}" ;; +esac + +exit 0