aboutsummaryrefslogtreecommitdiffstats
path: root/ncomp-sirius-manager-agent-server/src/main/server-gen/bin/sirius-manager-agent-server-controller
diff options
context:
space:
mode:
Diffstat (limited to 'ncomp-sirius-manager-agent-server/src/main/server-gen/bin/sirius-manager-agent-server-controller')
-rw-r--r--ncomp-sirius-manager-agent-server/src/main/server-gen/bin/sirius-manager-agent-server-controller137
1 files changed, 137 insertions, 0 deletions
diff --git a/ncomp-sirius-manager-agent-server/src/main/server-gen/bin/sirius-manager-agent-server-controller b/ncomp-sirius-manager-agent-server/src/main/server-gen/bin/sirius-manager-agent-server-controller
new file mode 100644
index 0000000..86a0713
--- /dev/null
+++ b/ncomp-sirius-manager-agent-server/src/main/server-gen/bin/sirius-manager-agent-server-controller
@@ -0,0 +1,137 @@
+#!/bin/bash
+
+# setup env if needed. java 6 required
+## JAVA_HOME=
+
+############################## DO NOT EDIT BELOW ##########################
+
+SNAME="Agent Controller"
+PNAME=sirius-manager-agent-server-controller
+CLASS=org.openecomp.ncomp.sirius.manager.agent.servers.monitoring.AgentSiriusManagerAgentServerServer
+
+############################## COMMON BELOW ##########################
+
+check_status ()
+{
+ if [ -f "${_PIDFILE}" ]; then
+ _PID=`cat "${_PIDFILE}"`
+ check_status_of_pid $_PID
+ else
+ _STATUS="$SNAME (no pidfile) is NOT running"
+ _RUNNING=0
+ fi
+}
+
+
+check_status_of_pid ()
+{
+ if [ -n "$1" ] && kill -0 $1 2>/dev/null ; then
+ _STATUS="$SNAME (pid $1) is running"
+ _RUNNING=1
+ else
+ _STATUS="$SNAME (pid $1) is NOT running"
+ _RUNNING=0
+ fi
+}
+
+
+check_status_of_pid ()
+{
+ if [ -n "$1" ] && kill -0 $1 2>/dev/null ; then
+ _STATUS="$SNAME (pid $1) is running"
+ _RUNNING=1
+ else
+ _STATUS="$SNAME (pid $1) is NOT running"
+ _RUNNING=0
+ fi
+}
+
+remove_pid_file ()
+{
+ if [ -f "${_PIDFILE}" ]; then
+ rm "${_PIDFILE}"
+ fi
+}
+
+
+_DIR=`dirname "$0"`
+_DIR=`dirname "$_DIR"`
+
+_PIDFILE=$_DIR/PID
+
+CMD=$1
+shift
+
+check_status
+case $CMD in
+ status)
+ echo $_STATUS
+ exit 0
+ ;;
+ console)
+ CP=$(find $_DIR/lib -name \*.jar | xargs -I X printf ":%s" X)
+ $GROOVY_HOME/bin/groovysh -cp $_DIR/config:$_DIR/lib:$CP
+ ;;
+ run)
+ CP=$(find $_DIR/lib -name \*.jar | xargs -I X printf ":%s" X)
+ $JAVA_HOME/bin/java -cp $_DIR/config:$_DIR/lib:$CP "$@"
+ ;;
+ groovy)
+ CP=$(find $_DIR/lib -name \*.jar | xargs -I X printf ":%s" X)
+ $GROOVY_HOME/bin/groovy -cp $_DIR/config:$_DIR/lib:$CP "$@"
+ ;;
+ start)
+ if [ "$_RUNNING" = "1" ]; then
+ echo $_STATUS
+ exit 0
+ fi
+ mkdir -p $_DIR/logs
+ if [ -e $_DIR/logs/$PNAME.out.1 ]; then mv $_DIR/logs/$PNAME.out.1 $_DIR/logs/$PNAME.out.2; fi
+ if [ -e $_DIR/logs/$PNAME.err.1 ]; then mv $_DIR/logs/$PNAME.err.1 $_DIR/logs/$PNAME.err.2; fi
+ if [ -e $_DIR/logs/$PNAME.out ]; then mv $_DIR/logs/$PNAME.out $_DIR/logs/$PNAME.out.1; fi
+ if [ -e $_DIR/logs/$PNAME.err ]; then mv $_DIR/logs/$PNAME.err $_DIR/logs/$PNAME.err.1; fi
+ CP=$(find $_DIR/lib -name \*.jar | xargs -I X printf ":%s" X)
+
+ nohup $JAVA_HOME/bin/java -cp $_DIR/config:$_DIR/lib:$CP "$@" $CLASS > $_DIR/logs/$PNAME.out 2> $_DIR/logs/$PNAME.err &
+
+ _PID=$!
+ echo $_PID > $_PIDFILE
+ sleep 5
+ check_status
+ echo $_STATUS
+ if [ "$_RUNNING" = "1" ]; then
+ exit 0
+ else
+ echo "Failed to start - make sure the $SNAME is fully configured properly"
+ exit 1
+ fi
+ ;;
+ stop)
+ if [ "$_RUNNING" = "0" ]; then
+ echo $_STATUS
+ remove_pid_file
+ exit 0
+ fi
+ echo "Stopping $SNAME..."
+ _PID_TO_KILL=$_PID;
+ echo "$SNAME (pid=${_PID_TO_KILL}) is stopping..."
+ kill -TERM $_PID_TO_KILL
+ sleep 5
+ check_status_of_pid $_PID_TO_KILL
+ if [ "$_RUNNING" = "1" ]; then
+ kill -TERM $_PID_TO_KILL
+ fi
+ while [ "$_RUNNING" = "1" ]; do
+ sleep 2
+ check_status_of_pid $_PID_TO_KILL
+ done
+ remove_pid_file
+ echo "$SNAME has stopped."
+ exit 0
+ ;;
+ *)
+ echo "$0 start|stop"
+ ;;
+esac
+
+