3 SNAME="Policy Management"
4 PNAME=policy-management
5 CLASS=org.openecomp.policy.drools.system.Main
10 if [[ ${RETVAL} != 0 ]]; then
17 # unmonitored start, does not change monitor status (immutable)
20 if [ "$_RUNNING" = "1" ]; then
26 if [ -e $_DIR/logs/$PNAME.out.1 ]; then mv $_DIR/logs/$PNAME.out.1 $_DIR/logs/$PNAME.out.2; fi
27 if [ -e $_DIR/logs/$PNAME.err.1 ]; then mv $_DIR/logs/$PNAME.err.1 $_DIR/logs/$PNAME.err.2; fi
28 if [ -e $_DIR/logs/$PNAME.out ]; then mv $_DIR/logs/$PNAME.out $_DIR/logs/$PNAME.out.1; fi
29 if [ -e $_DIR/logs/$PNAME.err ]; then mv $_DIR/logs/$PNAME.err $_DIR/logs/$PNAME.err.1; fi
30 CP=$(ls $_DIR/lib/*.jar | xargs -I X printf ":%s" X)
32 # If 'system.properties' exists, convert it into JVM arguments.
33 # Note that the following also handles property values with spaces.
36 if [[ -f $_DIR/config/system.properties ]] ; then
37 sed -n -e 's/^[ \t]*\([^ \t#]*\)[ \t]*=[ \t]*\(.*\)$/-D\1=\2/p' \
38 $_DIR/config/system.properties
44 if [[ "${cfg}" != "" ]] ; then
45 # need to make sure that we don't pass the lock file descriptor
49 nohup $JAVA_HOME/bin/java -Dkie.maven.settings.custom=$_DIR/config/kie_settings.xml -Dlog4j.configuration=file:$_DIR/config/log4j.properties -cp $_DIR/config:$_DIR/lib:$CP "${systemProperties[@]}" "$@" $CLASS > >( while read line; do echo "$(date): ${line}"; done > $_DIR/logs/$PNAME.out) 2> >( while read line; do echo "$(date): ${line}"; done > $_DIR/logs/$PNAME.err) &
52 echo $_PID > $_PIDFILE
57 if [ "$_RUNNING" = "1" ]; then
60 echo "Failed to start"
71 # unmonitored stop, does not change monitor status (immutable)
74 if [ "$_RUNNING" = "0" ]; then
78 if [[ -n ${ENGINE_MANAGEMENT_PASSWORD} ]]; then
79 http_proxy= curl --silent --user ${ENGINE_MANAGEMENT_USER}:${ENGINE_MANAGEMENT_PASSWORD} -X DELETE http://localhost:${ENGINE_MANAGEMENT_PORT}/policy/pdp/engine -o /dev/null
81 http_proxy= curl --silent -X DELETE http://localhost:${ENGINE_MANAGEMENT_PORT}/policy/pdp/engine -o /dev/null
84 echo "Stopping $SNAME..."
86 echo "$SNAME (pid=${_PID_TO_KILL}) is stopping..."
87 kill -TERM $_PID_TO_KILL 2> /dev/null
89 check_status_of_pid $_PID_TO_KILL
90 if [ "$_RUNNING" = "1" ]; then
91 kill -TERM $_PID_TO_KILL
93 while [ "$_RUNNING" = "1" ]; do
95 check_status_of_pid $_PID_TO_KILL
98 echo "$SNAME has stopped."
104 if [ -f "${_PIDFILE}" ]; then
105 _PID=`cat "${_PIDFILE}"`
106 check_status_of_pid $_PID
108 _STATUS="$SNAME (no pidfile) is NOT running"
111 if [[ $_RUNNING = 1 ]]; then
119 function check_status_of_pid ()
121 if [ -n "$1" ] && kill -0 $1 2>/dev/null ; then
122 _STATUS="$SNAME (pid $1) is running"
125 _STATUS="$SNAME (pid $1) is NOT running"
130 function remove_pid_file ()
132 if [ -f "${_PIDFILE}" ]; then
137 function update_monitor() {
139 if [[ -f ${POLICY_HOME}/etc/monitor/monitor.cfg ]]; then
141 -e "s/^${CONTROLLER}=.*/${CONTROLLER}=${STATUS}/g" \
142 ${POLICY_HOME}/etc/monitor/monitor.cfg
150 CONTROLLER=policy-management-controller
154 _PIDFILE=${POLICY_HOME}/PID
162 if flock ${cfg} ; then
164 fi {cfg}>>${POLICY_HOME}/etc/monitor/monitor.cfg.lock
170 if flock ${cfg} ; then
172 fi {cfg}>>${POLICY_HOME}/etc/monitor/monitor.cfg.lock
178 if flock ${cfg} ; then
182 fi {cfg}>>${POLICY_HOME}/etc/monitor/monitor.cfg.lock
185 echo "error: invalid option $@"
186 echo "Usage: $0 status|start|stop|restart"