forked from ionorg/ion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathislbStart.sh
executable file
·62 lines (53 loc) · 1.09 KB
/
islbStart.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
61
#!/bin/bash
APP_DIR=$(cd `dirname $0`/../; pwd)
cd $APP_DIR
mkdir -p $APP_DIR/logs
EXE=islb
COMMAND=$APP_DIR/bin/$EXE
CONFIG=$APP_DIR/configs/islb.toml
PID_FILE=$APP_DIR/configs/islb.pid
LOG_FILE=$APP_DIR/logs/islb.log
help()
{
echo ""
echo "start script"
echo "Usage: ./islbStart.sh [-h]"
echo ""
}
while getopts "h" arg
do
case $arg in
h)
help;
exit 0
;;
?)
echo "No argument needed. Ignore them all!"
;;
esac
done
count=`ps -ef |grep " $COMMAND " |grep -v "grep" |wc -l`
if [ 0 != $count ];then
ps aux | grep " $COMMAND " | grep -v "grep"
echo "already start"
exit 1;
fi
if [ ! -r $CONFIG ]; then
echo "$CONFIG not exsist"
exit 1;
fi
## build first
cd $APP_DIR/cmd/islb
go build -o $COMMAND
cd $APP_DIR
## run command
echo "nohup $COMMAND -c $CONFIG >>$LOG_FILE 2>&1 &"
nohup $COMMAND -c $CONFIG >>$LOG_FILE 2>&1 &
pid=$!
echo "$pid" > $PID_FILE
rpid=`ps aux | grep $pid |grep -v "grep" | awk '{print $2}'`
if [[ $pid != $rpid ]];then
echo "start failly."
rm $PID_FILE
exit 1
fi