Mercurial > dive4elements > river
comparison contrib/init.d/d4e-river @ 7738:1709c429818a
(issue1692) Ãberarbeitetes Init script
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 04 Feb 2014 11:08:57 +0100 |
parents | bc4e1bf26227 |
children | 0000ed802cad |
comparison
equal
deleted
inserted
replaced
7737:f4e32ac4e55c | 7738:1709c429818a |
---|---|
11 # Short-Description: Dive4Elements server | 11 # Short-Description: Dive4Elements server |
12 # Description: Start Dive4Elements server | 12 # Description: Start Dive4Elements server |
13 ### END INIT INFO | 13 ### END INIT INFO |
14 | 14 |
15 RUNAS=flys | 15 RUNAS=flys |
16 DIR="/opt/flys/current/server" | 16 START_SCRIPT="/opt/flys/d4e-start" |
17 NAME="$(basename $0)" | |
18 SHUTDOWN_WAIT="30" | |
17 | 19 |
18 CLASSPATH= | 20 export FLYSDIR="/opt/flys/current/server" |
19 for l in `find "$DIR/bin/lib" -name \*.jar -print`; do | 21 |
20 CLASSPATH=$CLASSPATH:$l | 22 unset ISBOOT |
21 done | 23 if [ "${NAME:0:1}" = "S" -o "${NAME:0:1}" = "K" ]; then |
24 NAME="${NAME:3}" | |
25 ISBOOT="1" | |
26 fi | |
27 | |
28 # remove SUSE's rc name | |
29 if [ "${NAME:0:2}" = "rc" ]; then | |
30 NAME="${NAME:2}" | |
31 fi | |
22 | 32 |
23 | 33 |
24 LOGFILE=/var/log/d4e-river.log | 34 export LOGFILE=/var/log/d4e-river.log |
25 PIDFILE=/var/run/d4e-river.pid | 35 export ARGS="-Xmx256m \ |
26 ARGS="-Xmx256m \ | |
27 -server \ | 36 -server \ |
28 -Djava.awt.headless=true \ | 37 -Djava.awt.headless=true \ |
29 -Dflys.datacage.recommendations.development=false \ | 38 -Dflys.datacage.recommendations.development=false \ |
30 -Djava.io.tmpdir=\"$DIR/cache\" \ | 39 -Djava.io.tmpdir=$FLYSDIR/cache \ |
40 -Dflys.backend.enablejmx=true \ | |
31 -Dflys.uesk.keep.artifactsdir=false \ | 41 -Dflys.uesk.keep.artifactsdir=false \ |
32 -Dwsplgen.bin.path=\"$DIR/bin/wsplgen.exe\" \ | 42 -Dwsplgen.bin.path=$FLYSDIR/bin/wsplgen.exe \ |
33 -Dwsplgen.log.output=false \ | 43 -Dwsplgen.log.output=false \ |
34 -Dartifact.database.dir=\"$DIR/conf\"" | 44 -Dlog4j.configuration=file://$FLYSDIR/conf/log4j.properties \ |
35 MAINCLASS=org.dive4elements.artifactdatabase.App | 45 -Dartifact.database.dir=$FLYSDIR/conf" |
46 export MAINCLASS=org.dive4elements.artifactdatabase.App | |
36 | 47 |
37 # For SELinux we need to use 'runuser' not 'su' | 48 # For SELinux we need to use 'runuser' not 'su' |
38 if [ -x "/sbin/runuser" ]; then | 49 if [ -x "/sbin/runuser" ]; then |
39 SU="/sbin/runuser" | 50 SU="/sbin/runuser" |
40 else | 51 else |
41 SU="/bin/su" | 52 SU="/bin/su -m" |
42 fi | 53 fi |
54 | |
55 # pulled from RHEL4 /etc/rc.d/init.d/functions | |
56 function checkpid() { | |
57 local i | |
58 for i in $* ; do | |
59 if [ -d "/proc/${i}" ]; then | |
60 return 0 | |
61 fi | |
62 done | |
63 return 1 | |
64 } | |
65 | |
66 . /etc/rc.status | |
67 rc_reset | |
68 | |
69 function start() { | |
70 echo -n "Starting D4E-river server... " | |
71 if [ -f "/var/lock/subsys/${NAME}" ] ; then | |
72 if [ -f "/var/run/${NAME}.pid" ]; then | |
73 read kpid < /var/run/${NAME}.pid | |
74 if checkpid $kpid 2>&1; then | |
75 echo "$NAME process already running with pid $kpid" | |
76 rc_failed 0 | |
77 exit | |
78 else | |
79 echo "lock file found but no process running for pid $kpid, continuing" | |
80 rc_failed 7 | |
81 fi | |
82 fi | |
83 fi | |
84 | |
85 export D4E_PID="/var/run/${NAME}.pid" | |
86 touch $D4E_PID | |
87 chown $RUNAS $D4E_PID | |
88 touch $LOGFILE | |
89 chown $RUNAS $LOGFILE | |
90 | |
91 for l in `find "$FLYSDIR/bin/lib" -name \*.jar -print`; do | |
92 CLASSPATH=$CLASSPATH:$l | |
93 done | |
94 | |
95 export CLASSPATH | |
96 | |
97 $SU $RUNAS -c "$START_SCRIPT" | |
98 #>> $LOGFILE 2>&1 | |
99 RETVAL="$?" | |
100 if [ "$RETVAL" -eq 0 ]; then | |
101 rc_failed 0 | |
102 touch /var/lock/subsys/${NAME} | |
103 else | |
104 rc_failed 7 | |
105 fi | |
106 rc_status -v | |
107 } | |
108 | |
109 function stop() { | |
110 echo -n "Shutting down D4E-River" | |
111 if [ -f "/var/lock/subsys/${NAME}" ]; then | |
112 count="0" | |
113 if [ -f "/var/run/${NAME}.pid" ]; then | |
114 read kpid < /var/run/${NAME}.pid | |
115 kill $kpid | |
116 until [ "$(ps --pid $kpid | grep -c $kpid)" -eq "0" ] || \ | |
117 [ "$count" -gt "$SHUTDOWN_WAIT" ]; do | |
118 if [ "$SHUTDOWN_VERBOSE" = "true" ]; then | |
119 echo -n -e "\nwaiting for processes $kpid to exit" | |
120 fi | |
121 sleep 1 | |
122 let count="${count}+1" | |
123 done | |
124 if [ "$count" -gt "$SHUTDOWN_WAIT" ]; then | |
125 if [ "$SHUTDOWN_VERBOSE" = "true" ]; then | |
126 echo -n -e "\nkilling processes which didn't stop" | |
127 echo -n -e "after " | |
128 echo -n "$SHUTDOWN_WAIT seconds" | |
129 fi | |
130 kill -9 $kpid | |
131 fi | |
132 rc_failed 0 | |
133 if [ "$count" -gt "0" ]; then | |
134 echo -n -e "\n" | |
135 fi | |
136 fi | |
137 rm -f /var/lock/subsys/${NAME} /var/run/${NAME}.pid | |
138 fi | |
139 rc_status -v | |
140 } | |
141 | |
142 | |
143 | |
43 | 144 |
44 case "$1" in | 145 case "$1" in |
45 start) | 146 start) |
46 echo "Starting D4E-river server..." | 147 start |
47 $SU - $RUNAS -c "/usr/bin/java -classpath $CLASSPATH $ARGS $MAINCLASS" &> $LOGFILE & | |
48 PID=$! | |
49 echo $PID > $PIDFILE | |
50 ;; | 148 ;; |
51 stop) | 149 stop) |
52 echo "Stopping D4E-river server..." | 150 stop |
53 PID=`cat $PIDFILE` | |
54 STOPRES=0 | |
55 while [ $STOPRES -le 0 ] | |
56 do | |
57 kill -15 $PID &> /dev/null | |
58 STOPRES=$? | |
59 sleep 1 | |
60 done | |
61 echo "done." | |
62 ;; | 151 ;; |
63 restart) | 152 restart) |
64 $0 stop && $0 start | 153 $0 stop && $0 start |
65 ;; | 154 ;; |
66 *) | 155 *) |