diff options
| author | Paul Buetow <paul@buetow.org> | 2011-05-13 14:45:34 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2011-05-13 14:45:34 +0000 |
| commit | 6deaaad082e043f1a1b9934511804aac81cde4e3 (patch) | |
| tree | 26da1e736834f7f9db6224f36acf516b244879c9 | |
| parent | f6d96f69a1ecd79b8dbf99099e3b7c998e986bdf (diff) | |
added 'restart' command
| -rw-r--r-- | README | 6 | ||||
| -rw-r--r-- | bin/perldaemon | 38 |
2 files changed, 30 insertions, 14 deletions
@@ -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 <start|stop|restart|logrotate>" - exit 1 + echo "Usage: $0 <start|stop|restart|logrotate>" + exit 1 ;; esac - |
