Skip to content

Commit

Permalink
reimplement nohup; combined with daemon (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
binarymason committed Aug 1, 2019
1 parent 6faaf57 commit a8f08ba
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions dist/init/sysvinit/bashrpc
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,39 @@ DAEMON=/usr/local/bin/bashrpc
PIDFILE=/var/run/$NAME.pid
LOGFILE=/var/log/$NAME.log
CONFIGFILE=/etc/bashrpc/bashrpc.yml
RETVAL=0

test -x $DAEMON || exit 0

# source init.d functions
. /etc/init.d/functions

start() {
echo -n "Starting $NAME"
touch $LOGFILE
daemon --pidfile "$PIDFILE" "$DAEMON" -c "$CONFIGFILE" --log "$LOGFILE"
daemon --pidfile "$PIDFILE" "nohup $DAEMON -c $CONFIGFILE --log $LOGFILE" &>/dev/null &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
ps aux | grep $DAEMON | grep -v grep | tr -s " " | cut -d " " -f2 > $PIDFILE
fi
echo

success; echo
return "$RETVAL"
}

stop() {
killproc -p "$PIDFILE"
echo -n "Stopping $NAME"
killproc "$DAEMON"
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
rm -f "$PIDFILE"
success; echo
else
failure; echo
fi

return "$RETVAL"
}

reload() {
Expand All @@ -46,20 +66,16 @@ status() {

case "$1" in
start)
echo "Starting $NAME"
start
;;
stop)
echo "Stopping $NAME"
stop
;;
restart)
echo "Restarting $NAME"
stop
start
;;
reload)
echo "Reloading $NAME"
reload
;;
status)
Expand Down

0 comments on commit a8f08ba

Please sign in to comment.