-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcontrol.sh
61 lines (54 loc) · 1.38 KB
/
control.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
BASEPATH="$(dirname "$PWD")"
TARGET=$1
CMD=$2
if [[ "$TARGET" == "api" ]]; then
NAME=pawket-api
WORKPATH=$BASEPATH/bin/api
BINARY=WalletServer.dll
elif [[ "$TARGET" == "syncer" ]]; then
NAME=pawket-syncer
WORKPATH=$BASEPATH/bin/syncer
BINARY=NodeDBSyncer.dll
else
echo "wrong target type, must be api/syncer"
exit 7
fi
PIDFILE=$BASEPATH/pid/${NAME}
if [[ "$CMD" == "status" ]]; then
daemon --name=$NAME --pidfile=$PIDFILE --running
if [ $? -ne 0 ]; then
echo "$NAME is stopped"
else
echo "$NAME is running"
fi
elif [[ "$CMD" == "start" ]]; then
daemon --name=$NAME --pidfile=$PIDFILE --running
if [ $? -ne 0 ]; then
cd $WORKPATH
source $BASEPATH/config/$NAME
nohup daemon --name="$NAME" --respawn -f --pidfile=$PIDFILE --output=$BASEPATH/log/${NAME}.log dotnet $BINARY >/dev/null 2>&1 &
echo "$NAME started"
else
echo "$NAME is already running"
fi
elif [[ "$CMD" == "stop" ]]; then
daemon --name=$NAME --pidfile=$PIDFILE --running
if [ $? -ne 0 ]; then
echo "$NAME is already stopped"
else
pid=$(head -n 1 $PIDFILE)
daemon --name=$NAME --pidfile=$PIDFILE --stop
echo -n "waiting previous process[$pid] exit"
while [ -e /proc/$pid ]
do
echo -n .
sleep .5
done
echo
echo "$NAME stopped"
fi
else
echo "wrong command, supported: status/start/stop"
exit 8
fi