From 332935f40dd4bdd076058187ae5489903488455b Mon Sep 17 00:00:00 2001 From: Sanju Abraham Date: Tue, 31 May 2016 18:06:53 -0700 Subject: [PATCH] On calling sudo supervisor-config restart, the echo in start function closes the python subprocess shell. Hence moving it to end of function Fixed ifmap-server script to start / stop java irond via supervisor Closes-Bug #1587645 Change-Id: Icded331091910fcd9d033d2739f4438071f230f9 (cherry picked from commit 7245367e0c368042dc81315063bd8104f55dbbf5) --- .../contrail-config.supervisor-config.upstart | 20 +++++++++++ debian/ifmap-server/debian/changelog | 6 ++++ .../ifmap-server/debian/scripts/ifmap-server | 5 ++- rpm/contrail/supervisor-config.initd | 33 +++++++++++++++++-- 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/debian/contrail/debian/contrail-config.supervisor-config.upstart b/debian/contrail/debian/contrail-config.supervisor-config.upstart index 440ad54b..ebc770c3 100644 --- a/debian/contrail/debian/contrail-config.supervisor-config.upstart +++ b/debian/contrail/debian/contrail-config.supervisor-config.upstart @@ -17,6 +17,26 @@ pre-start script ulimit -d unlimited ulimit -v unlimited ulimit -n 4096 + # cleanup subprocesses that are not reaped by supervisord, so that lifecycle management + # of the programs is with supervisord (config) + if [[ ! -z `ps -ef | grep contrail-discovery | grep -v grep | awk '{print $2}'` ]]; then + pkill -9 -f contrail-discovery + fi + if [[ ! -z `ps -ef | grep irond.jar | grep -v grep | awk '{print $2}'` ]]; then + pkill -9 -f irond.jar + fi + if [[ ! -z `ps -ef | grep contrail-api | grep -v grep | awk '{print $2}'` ]]; then + pkill -9 -f contrail-api + fi + if [[ ! -z `ps -ef | grep contrail-schema | grep -v grep | awk '{print $2}'` ]]; then + pkill -9 -f contrail-schema + fi + if [[ ! -z `ps -ef | grep contrail-svc-monitor | grep -v grep | awk '{print $2}'` ]]; then + pkill -9 -f contrail-svc-monitor + fi + if [[ ! -z `ps -ef | grep contrail-device-manager | grep -v grep | awk '{print $2}'` ]]; then + pkill -9 -f contrail-device-manager + fi end script #exec /usr/bin/supervisord --nodaemon -c /etc/contrail/supervisord_config.conf diff --git a/debian/ifmap-server/debian/changelog b/debian/ifmap-server/debian/changelog index c027b87c..7e8c650a 100644 --- a/debian/ifmap-server/debian/changelog +++ b/debian/ifmap-server/debian/changelog @@ -1,3 +1,9 @@ +ifmap-server (0.3.2-1contrail3) precise; urgency=low + * Launch line updated to allow supervisor restart + on ifmap abnormal termination. + + -- Sanju Abraham Tue, 31 May 2016 19:28:30 -0700 + ifmap-server (0.3.2-1contrail2) precise; urgency=low * Launch line updated to allow log-rotation correctly (commit ab71b8d502fd6c34e439c82af931dd5a559a34d1) diff --git a/debian/ifmap-server/debian/scripts/ifmap-server b/debian/ifmap-server/debian/scripts/ifmap-server index 8f66681c..e9ae76d5 100644 --- a/debian/ifmap-server/debian/scripts/ifmap-server +++ b/debian/ifmap-server/debian/scripts/ifmap-server @@ -1,4 +1,7 @@ #!/bin/sh cd /usr/share/ifmap-server -java -cp ./lib/ -jar ./irond.jar >> /var/log/contrail/ifmap-server-console.log 2>&1 +# exec to allow supervisor reap for ifmap process, enabling proper detection and life cycle +# management of the ifmap process. Use the explicit Dlog4j option to allow ifmap process to +# be noticed by ps command and also for user contrail to run ifmap process +exec /usr/bin/java -jar ./irond.jar -Dlog4j.configuration=file:////usr/share/ifmap-server/log4j.properties diff --git a/rpm/contrail/supervisor-config.initd b/rpm/contrail/supervisor-config.initd index 70a0d188..b90aa560 100644 --- a/rpm/contrail/supervisor-config.initd +++ b/rpm/contrail/supervisor-config.initd @@ -16,25 +16,52 @@ function log_failure_msg() { PID_FILE=/var/run/supervisord-config.pid function daemon_start() { - echo -n "Starting Supervisor Daemon for Contrail Config Package" ulimit -s unlimited ulimit -c unlimited ulimit -d unlimited ulimit -v unlimited ulimit -n 4096 + retval=false + socketon=false + if [[ ! -z `ps -ef | grep contrail-discovery | grep -v grep | awk '{print $2}'` ]]; then + pkill -9 -f contrail-discovery + fi + if [[ ! -z `ps -ef | grep irond.jar | grep -v grep | awk '{print $2}'` ]]; then + pkill -9 -f irond.jar + fi + if [[ ! -z `ps -ef | grep contrail-api | grep -v grep | awk '{print $2}'` ]]; then + pkill -9 -f contrail-api + fi + if [[ ! -z `ps -ef | grep contrail-schema | grep -v grep | awk '{print $2}'` ]]; then + pkill -9 -f contrail-schema + fi + if [[ ! -z `ps -ef | grep contrail-svc-monitor | grep -v grep | awk '{print $2}'` ]]; then + pkill -9 -f contrail-svc-monitor + fi + if [[ ! -z `ps -ef | grep contrail-device-manager | grep -v grep | awk '{print $2}'` ]]; then + pkill -9 -f contrail-device-manager + fi /usr/bin/supervisord -c /etc/contrail/supervisord_config.conf RETVAL=$? if [ $RETVAL -ne 0 ]; then - echo "supervisor-config start failed. checking lsof.." + retval=true lsof | grep -i supervisord_config.sock if [ $? -eq 0 ]; then - echo "Another program listening on same socket" + socketon=true pid=`lsof | grep -i supervisord_config.sock | cut -d' ' -f3` if [ "x$pid" != "x" ] ; then ps uw -p $pid fi fi fi + if [[ "retval" == true ]]; then + echo "supervisor-config start failed. checking lsof.." + if [[ "socketon" == true ]]; then + echo "Another program listening on same socket" + fi + else + echo -n "Started Supervisor Daemon for Contrail Config Package" + fi } function daemon_stop() {