Stop openidm linux service fails on centos 7

Tagged: , ,

This topic has 0 replies, 1 voice, and was last updated 4 years, 6 months ago by cristianoburgo.

  • Author
    Posts
  • #17469
     cristianoburgo
    Participant

    i have created the startup scritp for openidm on a CENTOS 7 machine.
    The service is started correctly as openidm user but when i try to stop it with /etc/init.d/openidm stop
    the service don’t stop. I can stop the service only issuing the command : pkill java .
    The pid file is created correctly.

    This is my file:

    #!/bin/sh
    
    # chkconfig: 345 95 5
    # description: start/stop openidm
    
    # clean up left over pid files if necessary
    cleanupPidFile() {
      if [ -f $OPENIDM_PID_FILE ]; then
        rm -f "$OPENIDM_PID_FILE"
      fi
      trap - EXIT
      exit
    }
    
    JAVA_BIN=/bin/java
    OPENIDM_HOME=/home/openidm/openidm
    OPENIDM_USER=openidm
    OPENIDM_PID_FILE=$OPENIDM_HOME/.openidm.pid
    OPENIDM_OPTS=""
    
    # Only set OPENIDM_OPTS if not already set
    [ -z "" ] && OPENIDM_OPTS="-Xmx1024m -Xms1024m -Dfile.encoding=UTF-8"
    
    cd ${OPENIDM_HOME}
    
    # Set JDK Logger config file if it is present and an override has not been issued
    if [ -z "$LOGGING_CONFIG" ]; then
      if [ -r "$OPENIDM_HOME"/conf/logging.properties ]; then
        LOGGING_CONFIG="-Djava.util.logging.config.file=$OPENIDM_HOME/conf/logging.properties"
      else
        LOGGING_CONFIG="-Dnop"
      fi
    fi
    
    CLASSPATH="$OPENIDM_HOME"/bin/*
    
    START_CMD="nohup $JAVA_BIN $LOGGING_CONFIG $JAVA_OPTS $OPENIDM_OPTS \
    		-Djava.endorsed.dirs=$JAVA_ENDORSED_DIRS \
    		-classpath \"$CLASSPATH\" \
    		-Djava.awt.headless=true \
                    -Dopenidm.system.server.root=$OPENIDM_HOME \
    		org.forgerock.commons.launcher.Main -c bin/launcher.json > logs/server.out 2>&1 &"
    
    case "${1}" in
    start)
    	su $OPENIDM_USER -c "$START_CMD eval echo \$\! > $OPENIDM_PID_FILE"
      	exit ${?}
      ;;
    stop)
    	./shutdown.sh > /dev/null
    	exit ${?}
      ;;
    restart)
    	./shutdown.sh > /dev/null
    	su $OPENIDM_USER -c "$START_CMD eval echo \$\! > $OPENIDM_PID_FILE"
      	exit ${?}
      ;;
    *)
      echo "Usage: openidm { start | stop | restart }"
      exit 1
      ;;
    esac

    While using the openidm user if i run these commands to start and stop all is working fine:

    #STARTUP OPENIDM
    nohup ./openidm/startup.sh > ./openidm/logs/server.out 2>&1&
    
    #STOP OPENIDM
    
    ./openidm/shutdown.sh
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

©2021 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?