3 # init script for a Java application
6 function update_monitor() {
9 if [[ -f ${POLICY_HOME}/etc/monitor/monitor.cfg ]]; then
11 -e "s/^${COMPONENT}=.*/${COMPONENT}=${STATUS}/g" \
12 ${POLICY_HOME}/etc/monitor/monitor.cfg
16 # unmonitored start, does not change monitor status (immutable)
18 JMX_JAVA_OPTS="-Dcom.sun.management.jmxremote"
19 JMX_JAVA_OPTS="${JMX_JAVA_OPTS} -Dcom.sun.management.jmxremote.port=${LOGPARSER_JMX_PORT}"
20 JMX_JAVA_OPTS="${JMX_JAVA_OPTS} -Dcom.sun.management.jmxremote.ssl=false"
21 JMX_JAVA_OPTS="${JMX_JAVA_OPTS} -Dcom.sun.management.jmxremote.authenticate=false"
22 JVM_JAVA_OPTS="-Xms${LOGPARSER_X_MS_MB}M -Xmx${LOGPARSER_X_MX_MB}M"
24 JAVA_OPTS="${JAVA_OPTS} ${JMX_JAVA_OPTS} ${JVM_JAVA_OPTS}"
26 # Redirects default and error output to a log file
27 cd ${POLICY_HOME}/servers/${COMPONENT}/bin
28 mkdir -p ${POLICY_LOGS}/policy/${COMPONENT} 2>/dev/null
29 nohup $JAVA_HOME/bin/java -jar ${JAVA_OPTS} ${SERVICE} ${SERVER} ${LOGTYPE} >> ${POLICY_LOGS}/policy/${COMPONENT}/stdout 2>&1 &
34 # Starts the application
37 if [[ ${RETVAL} != 0 ]]; then
38 update_monitor ${COMPONENT} off
40 update_monitor ${COMPONENT} on
44 # unmonitored stop, does not change monitor status (immutable)
46 # Kills the application process
47 pkill -u ${POLICY_USER} -f "${SERVICE} ${SERVER} ${LOGTYPE}" -TERM
49 if [[ ${RETVAL} != 0 ]]; then
51 pkill -u ${POLICY_USER} -f "${SERVICE} ${SERVER} ${LOGTYPE}" -KILL
56 # Stops the application
59 update_monitor ${COMPONENT} off
62 # Show the application status
65 pid=$(pgrep -f -u ${POLICY_USER} "${SERVICE} ${SERVER} ${LOGTYPE}" 2> /dev/null)
68 # If the PID was returned means the application is running
69 if [ ${RETVAL} -eq 0 ] ; then
70 echo "running with pid ${pid}"
76 # Main logic, a simple case to call functions
78 # determine if this is a paplp or pdplp component
79 COMPONENT=$(basename $0)
81 CONF_FILE="${POLICY_HOME}/servers/${COMPONENT}/bin/parserlog.properties"
82 SERVICE="${POLICY_HOME}/servers/${COMPONENT}/bin/logparser.jar"
86 configfile="dos_or_unix" # set the actual path name of your (DOS or Unix) config file
87 while IFS='= ' read lhs rhs
89 if [[ ! $lhs =~ ^\ *# && -n $lhs ]]; then
90 rhs="${rhs%%\#*}" # Del in line right comments
91 rhs="${rhs%%*( )}" # Del trailing spaces
92 rhs="${rhs%\"*}" # Del opening string quotes
93 rhs="${rhs#\"*}" # Del closing string quotes
94 if [[ $lhs != *"."* ]]; then
100 echo "error: cannot source configuration ${CONF_FILE}"
126 echo "Usage: $0 {start|stop|umstart|umstop|restart|status}"