forked from joelrosario/ginger
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathservice
executable file
·63 lines (50 loc) · 882 Bytes
/
service
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
#!/bin/sh
### BEGIN INIT INFO
# Provides: ginger
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Ginger at boot time
### END INIT INFO
BASE_DIR=`dirname $0`
BASE_DIR=`readlink -m $BASE_DIR`
BASE_DIR=`dirname $BASE_DIR`
BASE_DIR=`dirname $BASE_DIR`
PID_FILE=$BASE_DIR/unicorn.pid
CURRENT=$BASE_DIR/current
source ~/.bash_profile
function stop_service {
if [ -f $PID_FILE ]; then kill `cat $PID_FILE`; fi
while [ -f $PID_FILE ]; do
sleep 1
done
}
function start_service {
cd $CURRENT
if [ -f $PID_FILE ]
then
kill `cat $PID_FILE`
rm $PID_FILE
fi
rbenv exec unicorn -c $CURRENT/unicorn.rb -p 4567 -E development -D
}
case $1 in
start)
start_service
;;
stop)
stop_service
;;
restart)
stop_service
start_service
;;
status)
if [ -f $PID_FILE ]
then
echo PID: `cat $PID_FILE`
fi
;;
*)
echo Unexpected command
exit 1
esac