|
Revision 288, 2.3 KB
(checked in by daniel, 20 months ago)
|
|
startup script works from other directories
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | # |
|---|
| 4 | # A simple startup script |
|---|
| 5 | # |
|---|
| 6 | SCRIPT=$(readlink -f $0) |
|---|
| 7 | cd `dirname $SCRIPT` |
|---|
| 8 | |
|---|
| 9 | # Run this program |
|---|
| 10 | PROGRAM="java -cp .:jp/co/orkney/restlet:lib/antlrworks-1.1.3.jar:lib/org.restlet.ext.json_2.0.jar:lib/com.noelios.restlet.ext.simple_3.1.jar:lib/org.restlet.jar:lib/com.noelios.restlet.jar:lib/org.simpleframework.jar:lib/jdom.jar:lib/postgresql-8.1-413.jdbc3.jar:lib/org.json.jar:lib/commons-dbcp-1.2.2.jar:lib/commons-pool-1.4.jar:lib/com.noelios.restlet.ext.jdbc_3.0.jar jp.co.orkney.restlet.WebRouting" |
|---|
| 11 | |
|---|
| 12 | # In case "identifier" parameter is not set |
|---|
| 13 | if [ $2 ] |
|---|
| 14 | then |
|---|
| 15 | pidfile="log/restlet-$2.pid" |
|---|
| 16 | else |
|---|
| 17 | pidfile="log/restlet-wrs.pid" |
|---|
| 18 | fi |
|---|
| 19 | |
|---|
| 20 | # What should the service do? |
|---|
| 21 | case $1 in |
|---|
| 22 | start) |
|---|
| 23 | |
|---|
| 24 | echo " |
|---|
| 25 | Service starting ..." |
|---|
| 26 | |
|---|
| 27 | if [ -e "$pidfile" ] |
|---|
| 28 | then |
|---|
| 29 | |
|---|
| 30 | echo "Service is already running!" |
|---|
| 31 | echo "Do nothing ... |
|---|
| 32 | [$pidfile] |
|---|
| 33 | |
|---|
| 34 | " |
|---|
| 35 | else |
|---|
| 36 | $PROGRAM & |
|---|
| 37 | PID=$! |
|---|
| 38 | echo $PID > "$pidfile" |
|---|
| 39 | |
|---|
| 40 | echo "Service started! |
|---|
| 41 | [$pidfile|$PID] |
|---|
| 42 | |
|---|
| 43 | " |
|---|
| 44 | fi |
|---|
| 45 | ;; |
|---|
| 46 | |
|---|
| 47 | restart) |
|---|
| 48 | |
|---|
| 49 | echo " |
|---|
| 50 | Service restarting ..." |
|---|
| 51 | |
|---|
| 52 | if [ -e "$pidfile" ] |
|---|
| 53 | then |
|---|
| 54 | pid2kill=`cat $pidfile` |
|---|
| 55 | kill -9 $pid2kill |
|---|
| 56 | rm $pidfile |
|---|
| 57 | |
|---|
| 58 | echo "Service stopped!" |
|---|
| 59 | |
|---|
| 60 | else |
|---|
| 61 | |
|---|
| 62 | echo "No running service found ... starting a new one!" |
|---|
| 63 | |
|---|
| 64 | fi |
|---|
| 65 | |
|---|
| 66 | $PROGRAM & |
|---|
| 67 | PID=$! |
|---|
| 68 | echo $PID > "$pidfile" |
|---|
| 69 | |
|---|
| 70 | echo "Service started! |
|---|
| 71 | [$pidfile|$PID] |
|---|
| 72 | |
|---|
| 73 | " |
|---|
| 74 | ;; |
|---|
| 75 | |
|---|
| 76 | stop) |
|---|
| 77 | if [ -e "$pidfile" ] |
|---|
| 78 | then |
|---|
| 79 | pid2kill=`cat $pidfile` |
|---|
| 80 | kill -9 $pid2kill |
|---|
| 81 | rm $pidfile |
|---|
| 82 | |
|---|
| 83 | echo " |
|---|
| 84 | Service stopped! |
|---|
| 85 | [$pid2kill] |
|---|
| 86 | |
|---|
| 87 | " |
|---|
| 88 | else |
|---|
| 89 | echo " |
|---|
| 90 | No service found! |
|---|
| 91 | |
|---|
| 92 | " |
|---|
| 93 | fi |
|---|
| 94 | ;; |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | list) |
|---|
| 98 | # get current processes |
|---|
| 99 | echo " |
|---|
| 100 | Currently active WRS process(es): |
|---|
| 101 | " |
|---|
| 102 | |
|---|
| 103 | ps afx | grep restlet |
|---|
| 104 | |
|---|
| 105 | echo " |
|---|
| 106 | |
|---|
| 107 | " |
|---|
| 108 | ;; |
|---|
| 109 | |
|---|
| 110 | debug) |
|---|
| 111 | # run the program as is |
|---|
| 112 | echo " |
|---|
| 113 | Service starting in DEBUG mode ... |
|---|
| 114 | Type CTRL-C to stop the service. |
|---|
| 115 | |
|---|
| 116 | " |
|---|
| 117 | $PROGRAM |
|---|
| 118 | ;; |
|---|
| 119 | |
|---|
| 120 | help) |
|---|
| 121 | echo " |
|---|
| 122 | This is the Webrouting Service startup script |
|---|
| 123 | |
|---|
| 124 | Usage: |
|---|
| 125 | ./routingservice.sh {start|stop|restart|debug|list|help} [identifier] |
|---|
| 126 | |
|---|
| 127 | Commands: |
|---|
| 128 | start Start the service |
|---|
| 129 | stop Stop the service |
|---|
| 130 | restart Stop and immediately start the service again |
|---|
| 131 | debug Run the service in debug mode |
|---|
| 132 | This will print log messages to the terminal window. |
|---|
| 133 | list List currently active process(es) |
|---|
| 134 | help Show the startup help |
|---|
| 135 | |
|---|
| 136 | Optional: |
|---|
| 137 | identifier Run the service as a distinct process. |
|---|
| 138 | |
|---|
| 139 | " |
|---|
| 140 | ;; |
|---|
| 141 | |
|---|
| 142 | *) |
|---|
| 143 | echo " |
|---|
| 144 | Usage: ./routingservice.sh {start|stop|restart|debug|help} |
|---|
| 145 | |
|---|
| 146 | " |
|---|
| 147 | ;; |
|---|
| 148 | esac |
|---|