diff options
author | Geir Storli <geirst@verizonmedia.com> | 2019-03-29 12:54:26 +0000 |
---|---|---|
committer | Geir Storli <geirst@verizonmedia.com> | 2019-03-29 12:54:26 +0000 |
commit | b794e044098a4ba88335bc7e0686603ed50a41f0 (patch) | |
tree | 9fb375e321ec7215c5c3de65a450ea40c073c8a4 /logd/src/apps | |
parent | c02161249c161ee65f5a0be018439152b6cc8763 (diff) |
Prepare ConfigSubscriber to support instantiation of either legacy or rpc forwarder.
Diffstat (limited to 'logd/src/apps')
-rw-r--r-- | logd/src/apps/logd/main.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/logd/src/apps/logd/main.cpp b/logd/src/apps/logd/main.cpp index 229f385d416..067894e96d9 100644 --- a/logd/src/apps/logd/main.cpp +++ b/logd/src/apps/logd/main.cpp @@ -21,7 +21,6 @@ int main(int, char**) { StateReporter stateReporter; Metrics metrics(stateReporter.metrics()); - LegacyForwarder fwd(metrics); EV_STARTED("logdemon"); @@ -30,26 +29,27 @@ int main(int, char**) const char *cfid = getenv("VESPA_CONFIG_ID"); try { - ConfigSubscriber subscriber(fwd, config::ConfigUri(cfid)); + config::ConfigUri config_uri(cfid); + ConfigSubscriber subscriber(config_uri); + Forwarder::UP forwarder; int sleepcount = 0; while (true) { - Watcher watcher(subscriber, fwd); - try { subscriber.latch(); + if (!forwarder || subscriber.need_new_forwarder()) { + forwarder = subscriber.make_forwarder(metrics); + } + Watcher watcher(subscriber, *forwarder); + stateReporter.setStatePort(subscriber.getStatePort()); stateReporter.gotConf(subscriber.generation()); - int fd = subscriber.getservfd(); - if (fd >= 0) { - sleepcount = 0 ; // connection OK, reset sleep time - watcher.watchfile(); - } else { - LOG(spam, "bad fd in subscriber"); - } + + sleepcount = 0 ; // connection OK, reset sleep time + watcher.watchfile(); } catch (ConnectionException& ex) { LOG(debug, "connection exception: %s", ex.what()); - subscriber.closeConn(); + forwarder.reset(); } if (catcher.receivedStopSignal()) { throw SigTermException("caught signal"); |