root/trunk/nuxleus/Scripts/qs.sh

Revision 4777, 1.1 kB (checked in by xmlhacker, 3 months ago)

test data for SimpleDB

  • Property svn:executable set to *
Line 
1 #!/bin/sh
2 #
3 # qs - Manage a bucker queue server
4 #
5 PID_FILE=/tmp/qs.pid
6 PORT=9876
7 MEMCACHED_SERVERS=127.0.0.1:11211
8
9 function check_status  {
10     if [ -f $PID_FILE ]; then
11         PID=`cat $PID_FILE`
12         result=`ps -p $PID|grep $PID|grep -v grep`
13         case $result in
14                 "") echo "queue server is not running" ;;
15                 *) echo "queue server is running with PID: $PID" ;;
16         esac
17     else
18         echo "queue server is not running"
19     fi
20 }
21
22 function kill_server {
23     if [ -f $PID_FILE ]; then
24         PID=`cat $PID_FILE`
25         result=`ps -p $PID|grep $PID|grep -v grep`
26         case $result in
27                 *)
28                 `kill -USR1 $PID`
29                 `kill -15 $PID`
30                 `kill -9 $PID`
31                 ;;
32         esac
33     fi
34    
35 }
36
37 case $1 in
38
39 start)
40  
41   if [ $2 ]; then
42       MEMCACHED_SERVERS = $2
43   fi
44  
45   if [ $3 ]; then
46       PORT = $3
47   fi
48  
49   echo "Starting the queue server on port $PORT against memcached servers at $MEMCACHED_SERVERS"
50   /usr/local/bin/queue-server.py -s $MEMCACHED_SERVERS -p $PORT -i $PID_FILE &
51 ;;
52
53 stop)
54   echo "Stopping the queue server."
55   kill_server
56 ;;
57
58 status)
59         check_status
60 ;;
61
62 *)
63   echo "usage: $0 start|stop|status";
64 ;;
65
66 esac
67
68 # end of qs.sh
Note: See TracBrowser for help on using the browser.