aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bbot/agent.cli2
-rw-r--r--bbot/agent.cxx38
-rw-r--r--bbot/diagnostics12
-rw-r--r--bbot/diagnostics.cxx21
-rw-r--r--bbot/worker.cli5
-rw-r--r--bbot/worker.cxx7
6 files changed, 54 insertions, 31 deletions
diff --git a/bbot/agent.cli b/bbot/agent.cli
index 3e02807..5ca4457 100644
--- a/bbot/agent.cli
+++ b/bbot/agent.cli
@@ -39,7 +39,7 @@ namespace bbot
bool --systemd-daemon
{
- "Start as a simple systemd daemon."
+ "Run as a simple systemd daemon."
}
string --toolchain-name = "default"
diff --git a/bbot/agent.cxx b/bbot/agent.cxx
index b2beed8..8e13720 100644
--- a/bbot/agent.cxx
+++ b/bbot/agent.cxx
@@ -683,10 +683,6 @@ handle_signal (int sig)
}
}
-// Right arrow followed by newline.
-//
-const char systemd_indent[] = "\xE2\x86\xB2\n";
-
int
main (int argc, char* argv[])
try
@@ -696,34 +692,16 @@ try
verb = ops.verbose ();
- // Note that unlike other projects, here we distinguish between fail
- // (critical error, agent terminates) and error (non-fatal error, agent
- // continues to run). This means we should be careful not using fail
- // to report normal errors and vice-versa.
- //
if (ops.systemd_daemon ())
{
- // Map to systemd severity prefixes (see sd-daemon(3) for details). Note
- // that here we assume we will never have location (like file name which
- // would end up being before the prefix).
- //
- trace_indent =
- fail.indent_ =
- error.indent_ =
- warn.indent_ =
- info.indent_ =
- text.indent_ = systemd_indent;
-
- fail.type_ = "<2>";
- error.type_ = "<3>";
- warn.type_ = "<4>";
- info.type_ = "<6>";
- trace_type = "<7>";
-
- info << "bbot agent for " << tc_name << '/' << tc_num <<
- info << "toolchain id " << tc_id <<
- info << "CPU(s) " << ops.cpu () <<
- info << "RAM(kB) " << ops.ram ();
+ systemd_diagnostics (true); // With critical errors.
+
+ info << "bbot agent " << BBOT_VERSION_STR <<
+ info << "toolchain name " << tc_name <<
+ info << "toolchain num " << tc_num <<
+ info << "toolchain id " << tc_id <<
+ info << "CPU(s) " << ops.cpu () <<
+ info << "RAM(kB) " << ops.ram ();
}
tracer trace ("main");
diff --git a/bbot/diagnostics b/bbot/diagnostics
index 81cedcd..60df57c 100644
--- a/bbot/diagnostics
+++ b/bbot/diagnostics
@@ -149,6 +149,18 @@ namespace bbot
extern fail_mark fail;
extern const fail_end endf;
+
+ // Map to systemd severity prefixes (see sd-daemon(3) for details). Note
+ // that here we assume we will never have location (like file name which
+ // would end up being before the prefix).
+ //
+ // If with_critical is true, then distinguish between fail (critical error,
+ // daemon terminates) and error (non-fatal error, daemon continues to run).
+ // Note that this means we should be careful not to use fail to report
+ // normal errors and vice-versa.
+ //
+ void
+ systemd_diagnostics (bool with_critical);
}
#endif // BBOT_DIAGNOSTICS
diff --git a/bbot/diagnostics.cxx b/bbot/diagnostics.cxx
index 6ad2151..c6008c6 100644
--- a/bbot/diagnostics.cxx
+++ b/bbot/diagnostics.cxx
@@ -44,4 +44,25 @@ namespace bbot
fail_mark fail ("error: ");
const fail_end endf;
+
+ // Right arrow followed by newline.
+ //
+ const char systemd_indent[] = "\xE2\x86\xB2\n";
+
+ void
+ systemd_diagnostics (bool with_critical)
+ {
+ trace_indent =
+ fail.indent_ =
+ error.indent_ =
+ warn.indent_ =
+ info.indent_ =
+ text.indent_ = systemd_indent;
+
+ fail.type_ = with_critical ? "<2>" : "<3>";
+ error.type_ = "<3>";
+ warn.type_ = "<4>";
+ info.type_ = "<6>";
+ trace_type = "<7>";
+ }
}
diff --git a/bbot/worker.cli b/bbot/worker.cli
index 561d714..fd88521 100644
--- a/bbot/worker.cli
+++ b/bbot/worker.cli
@@ -52,6 +52,11 @@ namespace bbot
"Perform the environment setup and then re-execute for building."
}
+ bool --systemd-daemon
+ {
+ "Run as a simple systemd daemon."
+ }
+
dir_path --build
{
"<dir>",
diff --git a/bbot/worker.cxx b/bbot/worker.cxx
index fbae8c7..87dfdb4 100644
--- a/bbot/worker.cxx
+++ b/bbot/worker.cxx
@@ -480,6 +480,13 @@ try
verb = ops.verbose ();
+ if (ops.systemd_daemon ())
+ {
+ systemd_diagnostics (false);
+
+ info << "bbot worker " << BBOT_VERSION_STR;
+ }
+
// Version.
//
if (ops.version ())