-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappfm
executable file
·72 lines (61 loc) · 1.18 KB
/
appfm
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
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
dir=$(cd `dirname $0` && pwd)
source $dir/scripts/env.sh
export LD_LIBRARY_PATH=$ZMQ_LIB
bin="$CPM_HOME/lib/jdk1.8.0_51/bin/java -Djava.library.path=$ZMQ_LIB -jar $CPM_HOME/core/target/scala-2.11/cpm-core-server-assembly-1.0.jar $CPM_HOME/core/src/main/resources/conf.yml"
pid=$CPM_HOME/`hostname`-appfm.pid
mongopid=$CPM_HOME/`hostname`-mongo.pid
isRunning() {
ps ax | grep -e "^\s*$(cat $pid)\s\+" | wc -l
}
waitForStopped() {
i=$(isRunning)
while [ $i -ne 0 ]
do
sleep 1s
i=$(isRunning)
done
}
start() {
if [ -f $pid ] ; then
echo "pid file exists ($pid), AppFM may already be running"
else
if [[ $1 == "-d" || $1 == "--daemon" ]] ; then
echo "AppFM started in daemon mode"
nohup $bin > $CPM_HOME/`hostname`-appfm.log&
echo $! > $pid
else
echo "AppFM started"
$bin
fi
fi
}
stop() {
if [ -f $pid ] ; then
echo "AppFM stopped"
kill -15 `cat $pid`
waitForStopped
rm $pid
else
echo "no pid file found, AppFM may not be running"
fi
}
restart() {
stop
start $1
}
case "$1" in
start)
start $2
;;
stop)
stop
;;
restart)
restart $2
;;
*)
echo "Usage: appfm {start|stop|restart} [-d|--daemon]"
exit 1
;;
esac