summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2016-11-09 16:22:22 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-11-09 18:52:42 +0100
commit207e0d7a7909b75b2cb9d7bf8f8e817698bf55c9 (patch)
tree0859121ad132820afe7fbd3f109953c2423cce0a
parentzebra: Move netlink error message under a debug (diff)
downloadfrr-207e0d7a7909b75b2cb9d7bf8f8e817698bf55c9.tar.xz
frr-207e0d7a7909b75b2cb9d7bf8f8e817698bf55c9.zip
watchquagga: Signal when we are actually up and running
When Quagga is starting up, it is returning immediately. This is leaving us in a state where systemd believes Quagga is up and running, while the sytem might actually not have restarted the code yet. Modify the code so that when watchquagga starts up it doesn't start communicating with systemd until such time that it detects that all daemons are running. Additionally modify watchquagga to touch a file in /var/run/quagga/ that the /usr/lib/quagga/quagga script looks for for 10 seconds. If it finds this Quagga started file then we know watchquagga has successfully communicated with all daemons. If after 10 seconds we haven't communicated with Quagga, continue on for the start and let the normal start failure code work. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rwxr-xr-xtools/quagga14
-rw-r--r--watchquagga/watchquagga.c24
2 files changed, 35 insertions, 3 deletions
diff --git a/tools/quagga b/tools/quagga
index 83dfb6302..e8595d787 100755
--- a/tools/quagga
+++ b/tools/quagga
@@ -33,7 +33,6 @@ else
SSD=`which start-stop-daemon`
fi
-echo ${SSD}
# Print the name of the pidfile.
pidfile()
{
@@ -114,12 +113,23 @@ start()
echo -n " $1"
fi
+ if [ -e /var/run/quagga/watchquagga.started ] ; then
+ rm /var/run/quagga/watchquagga.started
+ fi
${SSD} \
--start \
--pidfile=`pidfile $1` \
--exec "$D_PATH/$1" \
-- \
"${watchquagga_options[@]}"
+ for i in `seq 1 10`;
+ do
+ if [ -e /var/run/quagga/watchquagga.started ] ; then
+ break
+ else
+ sleep 1
+ fi
+ done
elif [ -n "$2" ]; then
echo -n " $1-$2"
if ! check_daemon $1 $2 ; then
@@ -502,8 +512,8 @@ case "$1" in
if [ "$2" != "watchquagga" ]; then
start_prio 10 $dmn
fi
- vtysh_b
start_watchquagga
+ vtysh_b
;;
1|2|3|4|5|6|7|8|9|10)
diff --git a/watchquagga/watchquagga.c b/watchquagga/watchquagga.c
index e882653e3..cb9d50ff8 100644
--- a/watchquagga/watchquagga.c
+++ b/watchquagga/watchquagga.c
@@ -682,6 +682,28 @@ handle_read(struct thread *t_read)
return 0;
}
+/*
+ * Wait till we notice that all daemons are ready before
+ * we send we are ready to systemd
+ */
+static void
+daemon_send_ready (void)
+{
+ static int sent = 0;
+ if (!sent && gs.numdown == 0)
+ {
+#if defined (HAVE_CUMULUS)
+ FILE *fp;
+
+ fp = fopen("/var/run/quagga/watchquagga.started", "w");
+ fclose(fp);
+#endif
+ zlog_notice ("Watchquagga: Notifying Systemd we are up and running");
+ systemd_send_started(master, 0);
+ sent = 1;
+ }
+}
+
static void
daemon_up(struct daemon *dmn, const char *why)
{
@@ -689,6 +711,7 @@ daemon_up(struct daemon *dmn, const char *why)
gs.numdown--;
dmn->connect_tries = 0;
zlog_notice("%s state -> up : %s",dmn->name,why);
+ daemon_send_ready();
if (gs.do_ping)
SET_WAKEUP_ECHO(dmn);
phase_check();
@@ -1284,7 +1307,6 @@ main(int argc, char **argv)
gs.restart.interval = gs.min_restart_interval;
master = thread_master_create();
- systemd_send_started (master, 0);
signal_init (master, array_size(my_signals), my_signals);
srandom(time(NULL));