1 |
|
2 |
|
3 | nodefile=$1
|
4 | pidfile=$2
|
5 | logfile=$3
|
6 |
|
7 | pwd=$(pwd)
|
8 | service=${pwd##*/}
|
9 |
|
10 | if [ -e "$pidfile" ]
|
11 | then
|
12 | echo "[$service] Service is already running, $nodefile. PID=$(cat $pidfile)."
|
13 | exit 0
|
14 | fi
|
15 |
|
16 | nohup node $nodefile >> $logfile 2>&1 &
|
17 | PID=$!
|
18 |
|
19 | if [ $? -eq 0 ]
|
20 | then
|
21 | echo "[$service] Successfully started $nodefile. PID=$PID. Logs are at $logfile"
|
22 | echo $PID > $pidfile
|
23 | exit 0
|
24 | else
|
25 | echo "[$service] Could not start $nodefile - check logs at $logfile"
|
26 | exit 1
|
27 | fi
|