From d0ae606559207d9f5b16741cbe964ffdc334af45 Mon Sep 17 00:00:00 2001 From: Richard Whitehouse Date: Wed, 24 May 2017 20:30:46 +0000 Subject: [PATCH 1/2] Don't run Ralf if there is no Ralf hostname. Add/remove the monit script based on whether Ralf is present Prevent Ralf from starting if there is no configured Ralf hostname --- debian/ralf.init.d | 5 +++++ .../clearwater/infrastructure/scripts/ralf.monit | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/debian/ralf.init.d b/debian/ralf.init.d index c9b3136..c4b9a43 100644 --- a/debian/ralf.init.d +++ b/debian/ralf.init.d @@ -153,6 +153,11 @@ do_start() # 1 if daemon was already running # 2 if daemon could not be started + # Exit if there is no ralf hostname configured + if [ -z "$ralf_hostname" ]; then + return 2 + fi + # Allow us to write to the pidfile directory install -m 755 -o $NAME -g root -d /var/run/$NAME && chown -R $NAME /var/run/$NAME diff --git a/ralf.root/usr/share/clearwater/infrastructure/scripts/ralf.monit b/ralf.root/usr/share/clearwater/infrastructure/scripts/ralf.monit index 6d051ee..4e159a0 100755 --- a/ralf.root/usr/share/clearwater/infrastructure/scripts/ralf.monit +++ b/ralf.root/usr/share/clearwater/infrastructure/scripts/ralf.monit @@ -11,6 +11,20 @@ . /etc/clearwater/config +if [ -z "$ralf_hostname" ]; then + + if [ -f /etc/monit/conf.d/ralf.monit ]; then + rm /etc/monit/conf.d/ralf.monit + + # Force monit to reload its configuration + reload clearwater-monit || true + + # Stop ralf if it was running + service ralf stop + fi + +else + # Set up the monit configuration for ralf with the right IP addresses and ports cat > /etc/monit/conf.d/ralf.monit < Date: Tue, 13 Jun 2017 20:01:19 +0000 Subject: [PATCH 2/2] Resolve review markups --- debian/ralf.init.d | 5 ----- .../clearwater/infrastructure/scripts/ralf.monit | 11 ++++++----- src/main.cpp | 9 ++++++++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/debian/ralf.init.d b/debian/ralf.init.d index c4b9a43..c9b3136 100644 --- a/debian/ralf.init.d +++ b/debian/ralf.init.d @@ -153,11 +153,6 @@ do_start() # 1 if daemon was already running # 2 if daemon could not be started - # Exit if there is no ralf hostname configured - if [ -z "$ralf_hostname" ]; then - return 2 - fi - # Allow us to write to the pidfile directory install -m 755 -o $NAME -g root -d /var/run/$NAME && chown -R $NAME /var/run/$NAME diff --git a/ralf.root/usr/share/clearwater/infrastructure/scripts/ralf.monit b/ralf.root/usr/share/clearwater/infrastructure/scripts/ralf.monit index 4e159a0..4e9e5e4 100755 --- a/ralf.root/usr/share/clearwater/infrastructure/scripts/ralf.monit +++ b/ralf.root/usr/share/clearwater/infrastructure/scripts/ralf.monit @@ -25,8 +25,8 @@ if [ -z "$ralf_hostname" ]; then else -# Set up the monit configuration for ralf with the right IP addresses and ports -cat > /etc/monit/conf.d/ralf.monit < /etc/monit/conf.d/ralf.monit < remote_session_stores_locations; @@ -775,7 +782,7 @@ int main(int argc, char**argv) std::string chronos_callback_addr = "127.0.0.1:" + port_str; int http_af = AF_INET; - if (options.chronos_hostname == "" || options.ralf_hostname == "") + if (options.chronos_hostname == "") { // If we are using a local chronos cluster, we want Chronos to call back to // its local Ralf instance so that we can handle Ralfs failing without missing