From 6deaaad082e043f1a1b9934511804aac81cde4e3 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 13 May 2011 14:45:34 +0000 Subject: added 'restart' command --- README | 6 +++--- bin/perldaemon | 38 +++++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/README b/README index a607e2e..cfc5f15 100644 --- a/README +++ b/README @@ -14,14 +14,14 @@ It supports: QUICK START GUIDE: # Starting -./bin/perldaemon start +./bin/perldaemon start (or shortcut ./control start) # Stopping -./bin/perldaemon stop +./bin/perldaemon stop (or shortcut ./control stop) # Writing your own modules: cd ./lib/PerlDaemonModules/ cp ExampleModule.pm YourModule.pm vi YourModule.pm cd - -./bin/perldaemon restart +./bin/perldaemon restart (or shortcurt ./control restart) diff --git a/bin/perldaemon b/bin/perldaemon index 43c385a..685b478 100644 --- a/bin/perldaemon +++ b/bin/perldaemon @@ -1,5 +1,6 @@ #!/usr/bin/env bash +declare -r ARG=$1 declare -a LIBPATHS=(./lib ../lib /lib /usr/lib /usr/local/lib /opt/lib) for path in ${LIBPATHS[@]}; do @@ -9,30 +10,45 @@ for path in ${LIBPATHS[@]}; do fi done -function startPD () { perl -I$LIBDIR $LIBDIR/PerlDaemon/PerlDaemon.pl ./conf/perldaemon.conf } -function stopPD () { kill $(cat ./run/perldaemon.pid) } +if [ -z "$LIBDIR" ]; then + echo No PerlDaemon module path found + exit 1 +fi + +start () { + echo Starting daemon now... + perl -I$LIBDIR $LIBDIR/PerlDaemon/PerlDaemon.pl ./conf/perldaemon.conf +} + +stop () { + if [ -f ./run/perldaemon.pid ]; then + echo Stopping daemon now... + kill $(cat ./run/perldaemon.pid); + else + echo "No pidfile found (not running?) " + fi +} -case $1 in +case $ARG in start) - startPD + start ;; stop) - stopPD + stop ;; restart) - stopPD - startPD + stop + start ;; logrotate) - kill -HUP $(cat ./run/perldaemon.pid) + kill -HUP $(cat ./run/perldaemon.pid) ;; *) - echo "Usage: $0 " - exit 1 + echo "Usage: $0 " + exit 1 ;; esac - -- cgit v1.2.3