From f3ac83df5c4fec3f27a9c8f95ef2753a26c65d24 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 15 Jan 2010 13:09:32 -0800 Subject: [PATCH] Enable daemon monitoring and automatic restart by default. Tested on a XenServer by running "kill -SEGV" on the daemon processes and watching them restart automatically and by running plain "kill" and watching them terminate normally. --- debian/openvswitch-switch.init | 13 +++++++++++-- debian/openvswitch-switch.template | 4 ++++ xenserver/etc_init.d_vswitch | 18 ++++++++++++------ ...sr_share_vswitch_scripts_sysconfig.template | 6 +++++- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/debian/openvswitch-switch.init b/debian/openvswitch-switch.init index 5d37d707..1f65b693 100755 --- a/debian/openvswitch-switch.init +++ b/debian/openvswitch-switch.init @@ -33,11 +33,14 @@ DODTIME=1 # Time to wait for the server to die, in seconds unset OVSDB_SERVER_OPTS unset OVS_VSWITCHD_OPTS unset CORE_LIMIT +unset ENABLE_MONITOR default=/etc/default/openvswitch-switch if [ -f $default ] ; then . $default fi +: ${ENABLE_MONITOR:=y} + set -e # running_pid pid name @@ -209,11 +212,17 @@ case "$1" in /usr/share/openvswitch/vswitch-idl.ovsschema fi + if test "$ENABLE_MONITOR" = y; then + monitor_opt=--monitor + else + monitor_opt= + fi + # Start ovsdb-server. set -- set -- "$@" --verbose=ANY:console:emer --verbose=ANY:syslog:err set -- "$@" --log-file - set -- "$@" --detach --pidfile + set -- "$@" --detach --pidfile $monitor_opt set -- "$@" --remote punix:/var/run/ovsdb-server set -- "$@" /etc/openvswitch-switch/conf set -- "$@" $OVSDB_SERVER_OPTS @@ -232,7 +241,7 @@ case "$1" in set -- set -- "$@" --verbose=ANY:console:emer --verbose=ANY:syslog:err set -- "$@" --log-file - set -- "$@" --detach --pidfile + set -- "$@" --detach --pidfile $monitor_opt set -- "$@" unix:/var/run/ovsdb-server set -- "$@" $OVS_VSWITCHD_OPTS echo -n "Starting ovs-vswitchd: " diff --git a/debian/openvswitch-switch.template b/debian/openvswitch-switch.template index 6da1ed77..e36fc689 100644 --- a/debian/openvswitch-switch.template +++ b/debian/openvswitch-switch.template @@ -19,3 +19,7 @@ OVS_VSWITCHD_OPTS= # will disable core dumps. Setting it to "unlimited" will dump all # core files regardless of size. #CORE_LIMIT=unlimited + +# ENABLE_MONITOR: If 'y' then monitor daemon processes and restart them +# if they die due to an error signal. +# ENABLE_MONITOR=y diff --git a/xenserver/etc_init.d_vswitch b/xenserver/etc_init.d_vswitch index 788c4289..eb5dcb32 100755 --- a/xenserver/etc_init.d_vswitch +++ b/xenserver/etc_init.d_vswitch @@ -26,6 +26,7 @@ test -e /etc/sysconfig/vswitch && . /etc/sysconfig/vswitch # General config variables in /etc/sysconfig/vswitch : ${ENABLE_BRCOMPAT:=y} : ${ENABLE_FAKE_PROC_NET:=y} +: ${ENABLE_MONITOR:=y} : ${FORCE_COREFILES:=y} # Config variables specific to ovsdb-server @@ -81,7 +82,6 @@ appctl="/usr/bin/ovs-appctl" ofctl="/usr/bin/ovs-ofctl" vsctl="/usr/bin/ovs-vsctl" - if [ "$ENABLE_FAKE_PROC_NET" = "y" ]; then if [ "$ENABLE_BRCOMPAT" != "y" ]; then warning "FAKE_PROC_NET required BRCOMPAT which was disabled. Force enabling." @@ -89,6 +89,12 @@ if [ "$ENABLE_FAKE_PROC_NET" = "y" ]; then fi fi +if test "$ENABLE_MONITOR" = "y"; then + monitor_opt="--monitor" +else + monitor_opt= +fi + function dp_list { "$dpctl" show | grep '^dp[0-9]\+:' | cut -d':' -f 1 } @@ -168,9 +174,9 @@ function start_ovsdb_server { if [ "$daemonize" != "y" ]; then # Start in background and force a "success" message action "Starting ovsdb_server ($strace_opt$valgrind_opt)" true - (nice -n "$OVSDB_SERVER_PRIORITY" $strace_opt $valgrind_opt "$ovsdb_server" "$OVSDB_SERVER_DB" --pidfile="$OVSDB_SERVER_PIDFILE" --detach --no-chdir -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt $remotes) & + (nice -n "$OVSDB_SERVER_PRIORITY" $strace_opt $valgrind_opt "$ovsdb_server" "$OVSDB_SERVER_DB" --pidfile="$OVSDB_SERVER_PIDFILE" --detach $monitor_opt --no-chdir -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt $remotes) & else - action "Starting ovsdb-server" nice -n "$OVSDB_SERVER_PRIORITY" "$ovsdb_server" "$OVSDB_SERVER_DB" --pidfile="$OVSDB_SERVER_PIDFILE" --detach --no-chdir -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt $remotes + action "Starting ovsdb-server" nice -n "$OVSDB_SERVER_PRIORITY" "$ovsdb_server" "$OVSDB_SERVER_DB" --pidfile="$OVSDB_SERVER_PIDFILE" --detach $monitor_opt --no-chdir -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt $remotes fi } @@ -214,9 +220,9 @@ function start_vswitchd { if [ "$daemonize" != "y" ]; then # Start in background and force a "success" message action "Starting ovs-vswitchd ($strace_opt$valgrind_opt)" true - (nice -n "$VSWITCHD_PRIORITY" $strace_opt $valgrind_opt "$vswitchd" --pidfile="$VSWITCHD_PIDFILE" --detach --no-chdir $fake_proc_net_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_OVSDB_SERVER") & + (nice -n "$VSWITCHD_PRIORITY" $strace_opt $valgrind_opt "$vswitchd" --pidfile="$VSWITCHD_PIDFILE" --detach $monitor_opt --no-chdir $fake_proc_net_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_OVSDB_SERVER") & else - action "Starting ovs-vswitchd" nice -n "$VSWITCHD_PRIORITY" "$vswitchd" --pidfile="$VSWITCHD_PIDFILE" --detach --no-chdir $fake_proc_net_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_OVSDB_SERVER" + action "Starting ovs-vswitchd" nice -n "$VSWITCHD_PRIORITY" "$vswitchd" --pidfile="$VSWITCHD_PIDFILE" --detach $monitor_opt --no-chdir $fake_proc_net_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_OVSDB_SERVER" fi } @@ -259,7 +265,7 @@ function start_brcompatd { action "Starting ovs-brcompatd ($strace_opt$valgrind_opt)" true (nice -n "$VSWITCHD_PRIORITY" $strace_opt $valgrind_opt "$brcompatd"--no-chdir --appctl-command="$appctl_cmd" --pidfile=$BRCOMPATD_PIDFILE -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_OVSDB_SERVER") & else - action "Starting ovs-brcompatd" nice -n "$BRCOMPATD_PRIORITY" $strace_opt $valgrind_opt "$brcompatd" --no-chdir --appctl-command="$appctl_cmd" --pidfile=$BRCOMPATD_PIDFILE --detach -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_OVSDB_SERVER" + action "Starting ovs-brcompatd" nice -n "$BRCOMPATD_PRIORITY" $strace_opt $valgrind_opt "$brcompatd" --no-chdir --appctl-command="$appctl_cmd" --pidfile=$BRCOMPATD_PIDFILE --detach $monitor_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_OVSDB_SERVER" fi } diff --git a/xenserver/usr_share_vswitch_scripts_sysconfig.template b/xenserver/usr_share_vswitch_scripts_sysconfig.template index 2651cc3d..b9d7ecb2 100644 --- a/xenserver/usr_share_vswitch_scripts_sysconfig.template +++ b/xenserver/usr_share_vswitch_scripts_sysconfig.template @@ -1,6 +1,6 @@ ### Configuration options for vswitch -# Copyright (C) 2009 Nicira Networks, Inc. +# Copyright (C) 2009, 2010 Nicira Networks, Inc. # # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright @@ -17,6 +17,10 @@ # This is useful in some cases when replacing existing solutions. # ENABLE_FAKE_PROC_NET=y +# ENABLE_MONITOR: If 'y' then monitor daemon processes and restart them +# if they die due to an error signal. +# ENABLE_MONITOR=y + # FORCE_COREFILES: If 'y' then core files will be enabled. # FORCE_COREFILES=y -- 2.30.2