-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdaemoncontroller.dist
87 lines (77 loc) · 1.73 KB
/
daemoncontroller.dist
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/sh
#
# meteord This shell script takes care of starting and stopping
# the Meteor HTTP server (meteord).
#
#
# description: Runs meteord
# processname: meteord
# config: /etc/meteord.conf
# pidfile: /var/run/meteord.pid
# chkconfig: 2345 99 00
# Source function library.
. /etc/init.d/functions
case "$1" in
'start')
echo -n "Starting Meteord: "
# Check to see if it's already running:
PID=`cat "/var/run/meteord.pid" 2>/dev/null `
if [ -n "$PID" ]; then
kill -s 0 "$PID" >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo -n " Already running (pid $PID)"
failure
echo
exit 1
fi
fi
echo 65535 > /proc/sys/fs/file-max
ulimit -n 65535
touch /var/run/meteord.pid
chown meteor:meteor /var/run/meteord.pid
cd /usr/local/meteor
sudo -u meteor ./meteord >/var/log/meteord 2>&1 &
# Check it's still running:
sleep 1
PID=`cat "/var/run/meteord.pid" 2>/dev/null `
if [ -n "$PID" ]; then
kill -s 0 "$PID" 2>&1 >/dev/null && success || failure
else
failure
fi
;;
'stop')
echo -n "Stopping Meteord: "
PID=`cat "/var/run/meteord.pid" 2>/dev/null `
if [ -n "$PID" ]; then
/bin/kill "$PID" >/dev/null 2>&1 && success || failure
else
echo
echo "No process ID found." && failure
fi
;;
'restart')
echo -n "Restarting Meteord:"
warning
echo
echo " Normally you can use 'reload' rather than 'restart'"
$0 stop
$0 start
;;
'reload')
echo -n "Reloading Meteord configuration: "
PID=`cat "/var/run/meteord.pid" 2>/dev/null `
if [ -n "$PID" ]; then
kill -s HUP "$PID" && success || failure
else
echo
echo "No process ID found." && failure
fi
;;
*)
echo "Usage: $0 { start | stop | reload }"
;;
esac
echo
exit 0