UNPKG

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