Skip to content
Browse files

add a script to launch a process and generate pid file; add fastri su…

…pport in monitrc
  • Loading branch information...
1 parent 0deb0e4 commit 09eb80c1251960f8ed970cd8c09ffdb542a68246 @linsong committed Feb 24, 2011
Showing with 23 additions and 2 deletions.
  1. +3 −2 .monitrc
  2. +20 −0 tools/daemon_launcher.sh
View
5 .monitrc
@@ -239,5 +239,6 @@ check process mongodb with pidfile /Users/vincent/.mongodb/mongodb.pid
start program = "/opt/local/bin/mongod -f /Users/vincent/.mongodb.conf --pidfilepath /Users/vincent/.mongodb/mongodb.pid"
stop program = "/bin/bash -c '/bin/kill `/bin/cat /Users/vincent/.mongodb/mongodb.pid`'"
-check host localhost with address 127.0.0.1
- if failed port 53092 then exec "/bin/bash -c '/opt/local/bin/fastri-server'"
+check process fastri with pidfile /Users/vincent/.pids/fastri-server.pid
+ start program = "/Users/vincent/tools/daemon_launcher.sh start /opt/local/bin/fastri-server"
+ stop program = "/Users/vincent/tools/daemon_launcher.sh stop /opt/local/bin/fastri-server"
View
20 tools/daemon_launcher.sh
@@ -0,0 +1,20 @@
+#!/bin/bash -xv
+
+basename=$(basename $2)
+
+HOME=/Users/vincent
+mkdir -p $HOME/.pids
+
+case $1 in
+ start)
+ echo $$ > $HOME/.pids/$basename.pid ;
+ exec 2>&1 $2 1>/tmp/$basename.log
+ ;;
+ stop)
+ kill `cat $HOME/.pids/$basename.pid` ;
+ rm $HOME/.pids/$basename.pid
+ ;;
+ *)
+ echo "usage: daemon_launcher {start|stop} daemon_tool_name" ;;
+esac
+exit 0

0 comments on commit 09eb80c

Please sign in to comment.
Something went wrong with that request. Please try again.