X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=osgi%2Fdist%2Fosgi-boot%2Fsrc%2Fmain%2Frpm%2Fusr%2Fsbin%2Fosgi-service;h=6fbb1e41cdab9d9960e9c99c6733b1cfcd6ac862;hb=ed37ad5f3228e19d75cda12e366ccdc05170fbe4;hp=cbaecf5788cde451a084de527ded5b4bb4105da7;hpb=87a5c6c8c109097c8be2412f5a10df2de3a6e0c0;p=lgpl%2Fargeo-commons.git diff --git a/osgi/dist/osgi-boot/src/main/rpm/usr/sbin/osgi-service b/osgi/dist/osgi-boot/src/main/rpm/usr/sbin/osgi-service index cbaecf578..6fbb1e41c 100644 --- a/osgi/dist/osgi-boot/src/main/rpm/usr/sbin/osgi-service +++ b/osgi/dist/osgi-boot/src/main/rpm/usr/sbin/osgi-service @@ -16,7 +16,8 @@ LIB_DIR=/usr/share/$APP/lib EXEC_DIR=/var/lib/$APP DATA_DIR=$EXEC_DIR/data CONF_RW=$EXEC_DIR/conf -LOG_FILE=/var/log/$APP.log +LOG_DIR=/var/log/$APP +LOG_FILE=$LOG_DIR/$APP.log RUN_DIR=/var/run PID_FILE=$RUN_DIR/$APP.pid @@ -28,16 +29,26 @@ OSGI_FRAMEWORK=$OSGI_INSTALL_AREA/org.eclipse.osgi.jar RETVAL=0 start() { - cp $CONF_DIR/config.ini $CONF_RW/config.ini + if [ ! -d $LOG_DIR ];then + mkdir -m 0750 -p $LOG_DIR + touch $LOG_FILE + chown -R $APP.$APP $LOG_DIR + fi + + cp --preserve $CONF_DIR/config.ini $CONF_RW/config.ini touch $SHUTDOWN_FILE - cd $EXEC_DIR && $JVM \ + cd $EXEC_DIR + # start as user $APP + sudo -u $APP $JVM \ -Dosgi.bundles="org.argeo.osgi.boot.jar@start" \ -Dargeo.osgi.bundles="$CONF_DIR/modules;in=*,$LIB_DIR;in=*" \ + -Dargeo.osgi.shutdownFile="$SHUTDOWN_FILE" \ -Dlog4j.configuration="file:$CONF_DIR/log4j.properties" \ $JAVA_OPTS -jar $OSGI_FRAMEWORK \ + -clean \ -configuration "$CONF_RW" \ -data "$DATA_DIR" \ - &> $LOG_FILE & + &>> $LOG_FILE & PID=$! echo $PID > $PID_FILE echo Started $APP with pid $PID @@ -45,9 +56,21 @@ start() { } stop() { - PID=`cat $PID_FILE` + if [ -f $PID_FILE ];then + PID=`cat $PID_FILE` + else + echo $APP is not running + return $RETVAL + fi rm -f $SHUTDOWN_FILE - # TODO wait for process to finish until timeout, then kill + timeout 5m sh << EOF +while kill -0 $PID &> /dev/null; do sleep 1; done +EOF + TIMEOUT_EXIT=$? + if [ $TIMEOUT_EXIT -eq 124 ];then + kill -9 $PID + fi + rm -f $PID_FILE echo Stopped $APP with pid $PID return $RETVAL } @@ -60,21 +83,20 @@ case "$2" in stop) stop ;; - restart|reload) + restart) stop - sleep 10 start RETVAL=$? ;; - condrestart) - echo Not implemented - exit 1 - ;; status) - echo Not implemented - exit 1 + if [ -f $PID_FILE ];then + PID=`cat $PID_FILE` + echo $APP is running with pid $PID ... + else + echo $APP is not running + fi ;; *) - echo $"Usage: $0 {start|stop|restart}" + echo $"Usage: $0 {start|stop|restart|status}" exit 1 -esac +esac \ No newline at end of file