summaryrefslogtreecommitdiffstats
path: root/logd/src/apps
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-03-29 12:54:26 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-03-29 12:54:26 +0000
commitb794e044098a4ba88335bc7e0686603ed50a41f0 (patch)
tree9fb375e321ec7215c5c3de65a450ea40c073c8a4 /logd/src/apps
parentc02161249c161ee65f5a0be018439152b6cc8763 (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.cpp24
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");