-
Notifications
You must be signed in to change notification settings - Fork 0
/
patrick-server
89 lines (80 loc) · 2.06 KB
/
patrick-server
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
88
89
#!/bin/bash
### BEGIN INIT INFO
# If you wish the Daemon to be lauched at boot / stopped at shutdown :
#
# On Debian-based distributions:
# INSTALL : update-rc.d scriptname defaults
# (UNINSTALL : update-rc.d -f scriptname remove)
#
# On RedHat-based distributions (CentOS, OpenSUSE...):
# INSTALL : chkconfig --level 35 scriptname on
# (UNINSTALL : chkconfig --level 35 scriptname off)
#
# chkconfig: 2345 90 60
# Provides: /Users/gfay/Desktop/Projet NSY209/server/lib/main.js
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: forever running /Users/gfay/Desktop/Projet NSY209/server/lib/main.js
# Description: /Users/gfay/Desktop/Projet NSY209/server/lib/main.js
### END INIT INFO
#
# initd a node app
# Based on a script posted by https://gist.github.com/jinze at https://gist.github.com/3748766
#
if [ -e /lib/lsb/init-functions ]; then
# LSB source function library.
. /lib/lsb/init-functions
fi;
pidFile="/var/run/patrick-server.pid"
logFile="/var/run/patrick-server.log"
command="node"
nodeApp="/usr/local/patrick-server/lib/main.js"
foreverApp="forever"
start() {
echo "Starting $nodeApp"
# Notice that we change the PATH because on reboot
# the PATH does not include the path to node.
# Launching forever with a full path
# does not work unless we set the PATH.
PATH=/usr/local/bin:$PATH
export NODE_ENV=production
#PORT=80
$foreverApp start --pidFile $pidFile -l $logFile -a -d -c "$command" $nodeApp
RETVAL=$?
}
restart() {
echo -n "Restarting $nodeApp"
$foreverApp restart $nodeApp
RETVAL=$?
}
stop() {
echo -n "Shutting down $nodeApp"
$foreverApp stop $nodeApp
RETVAL=$?
}
status() {
echo -n "Status $nodeApp"
$foreverApp list
RETVAL=$?
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
*)
echo "Usage: {start|stop|status|restart}"
exit 1
;;
esac
exit $RETVAL