summaryrefslogtreecommitdiffstats
path: root/configd
diff options
context:
space:
mode:
authorArne Juul <arnej@yahooinc.com>2022-12-08 11:47:56 +0000
committerArne Juul <arnej@yahooinc.com>2022-12-08 12:08:11 +0000
commit4a71f31141c4a8ee63951e70a7d26a11f32c8f7f (patch)
tree0f9654cd695c6b32f57624bf5ee32957e9985380 /configd
parent6a4aa5fbd2e95a1df5854c61a8d3417242923321 (diff)
common apply, add unapply
Diffstat (limited to 'configd')
-rw-r--r--configd/src/apps/sentinel/logctl.cpp2
-rw-r--r--configd/src/apps/sentinel/service.cpp28
2 files changed, 19 insertions, 11 deletions
diff --git a/configd/src/apps/sentinel/logctl.cpp b/configd/src/apps/sentinel/logctl.cpp
index b63bdf52272..94759d4f102 100644
--- a/configd/src/apps/sentinel/logctl.cpp
+++ b/configd/src/apps/sentinel/logctl.cpp
@@ -17,7 +17,7 @@ void justRunLogctl(const char *cspec, const char *lspec)
const char *progName = "vespa-logctl";
pid_t pid = fork();
if (pid == 0) {
- LOG(debug, "running '%s' '%s' '%s'\n", progName, cspec, lspec);
+ LOG(debug, "running '%s' '%s' '%s'", progName, cspec, lspec);
int rv = execlp(progName, progName, "-c", cspec, lspec, nullptr);
if (rv != 0) {
LOG(warning, "execlp of '%s' failed: %s", progName, strerror(errno));
diff --git a/configd/src/apps/sentinel/service.cpp b/configd/src/apps/sentinel/service.cpp
index ad9d9c70d92..cb2c935956e 100644
--- a/configd/src/apps/sentinel/service.cpp
+++ b/configd/src/apps/sentinel/service.cpp
@@ -57,6 +57,21 @@ Service::Service(const SentinelConfig::Service& service, const SentinelConfig::A
start();
}
+void applyLogctl(const cloud::config::SentinelConfig::Service &config) {
+ for (const auto &logctl : config.logctl) {
+ const auto cspec = config.name + ":" + logctl.componentSpec;
+ const auto lspec = logctl.levelsModSpec;
+ justRunLogctl(cspec.c_str(), lspec.c_str());
+ }
+}
+
+void unApplyLogctl(const cloud::config::SentinelConfig::Service &config) {
+ for (const auto &logctl : config.logctl) {
+ const auto cspec = config.name + ":" + logctl.componentSpec;
+ justRunLogctl(cspec.c_str(), "all=on,debug=off,spam=off");
+ }
+}
+
void
Service::reconfigure(const SentinelConfig::Service& config)
{
@@ -71,14 +86,11 @@ Service::reconfigure(const SentinelConfig::Service& config)
terminate();
}
+ unApplyLogctl(*_config);
delete _config;
_config = new SentinelConfig::Service(config);
+ applyLogctl(*_config);
- for (const auto &logctl : _config->logctl) {
- const auto cspec = _config->name + ":" + logctl.componentSpec;
- const auto lspec = logctl.levelsModSpec;
- justRunLogctl(cspec.c_str(), lspec.c_str());
- }
if ((_state == READY) || (_state == FINISHED) || (_state == RESTARTING)) {
if (_isAutomatic) {
LOG(debug, "%s: Restarting due to new config", name().c_str());
@@ -335,11 +347,7 @@ Service::runChild()
for (const auto &envvar : _config->environ) {
setenv(envvar.varname.c_str(), envvar.varvalue.c_str(), 1);
}
- for (const auto &logctl : _config->logctl) {
- const auto cspec = _config->name + ":" + logctl.componentSpec;
- const auto lspec = logctl.levelsModSpec;
- justRunLogctl(cspec.c_str(), lspec.c_str());
- }
+ applyLogctl(*_config);
// Set up environment
setenv("VESPA_SERVICE_NAME", _config->name.c_str(), 1);