-
Notifications
You must be signed in to change notification settings - Fork 1
/
ddproxy.sh
executable file
·61 lines (56 loc) · 1.12 KB
/
ddproxy.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
if [ "$EUID" -ne 0 ]
then
LOG=/tmp/ddproxy.log
PID=/tmp/ddproxy.pid
else
LOG=/var/log/ddproxy.log
PID=/var/run/ddproxy.pid
fi
APP=server/index.js
NODE=node
SCRIPT=`readlink -f $0`
DIR=`dirname $SCRIPT`
startme() {
echo -n "Starting ddproxy.."
if [ -f $PID ]
then
echo ". Already started. PID: [$( cat $PID )]"
else
cd $DIR
$NODE $DIR/$APP >> $LOG 2>&1 &
echo $! > $PID
echo ". Done. PID: [$( cat $PID )]"
fi
}
stopme() {
echo -n "Stopping ddproxy.."
if [ -f $PID ]
then
kill $( cat $PID )
rm $PID
echo ". Done."
else
echo ". No pid file. Already stopped?"
fi
}
mystatus() {
echo -n "Status of ddproxy: "
if [ -f $PID ]
then
echo "Pid file $PID [$( cat $PID )]"
echo
ps -ef | grep -v grep | grep $( cat $PID )
else
echo "No Pid file"
fi
}
case "$1" in
start) startme ;;
stop) stopme ;;
restart) stopme; startme ;;
status) mystatus ;;
*) echo "Usage: $0 { start | stop | restart | status }" >&2
exit 1
;;
esac