summaryrefslogtreecommitdiffstats
path: root/src/core/unit.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-11-13 17:14:07 +0100
committerLennart Poettering <lennart@poettering.net>2017-11-16 14:38:36 +0100
commit5afe510c89f26b0e721b276a0e78af914b47f0b0 (patch)
tree01b4c2c06fd8c2f737313fd02b35e08c9959ff35 /src/core/unit.h
parentunit: rework a bit how we keep the service fdstore from being destroyed durin... (diff)
downloadsystemd-5afe510c89f26b0e721b276a0e78af914b47f0b0.tar.xz
systemd-5afe510c89f26b0e721b276a0e78af914b47f0b0.zip
core: add a new unit file setting CollectMode= for tweaking the GC logic
Right now, the option only takes one of two possible values "inactive" or "inactive-or-failed", the former being the default, and exposing same behaviour as the status quo ante. If set to "inactive-or-failed" units may be collected by the GC logic when in the "failed" state too. This logic should be a nicer alternative to using the "-" modifier for ExecStart= and friends, as the exit data is collected and logged about and only removed when the GC comes along. This should be useful in particular for per-connection socket-activated services, as well as "systemd-run" command lines that shall leave no artifacts in the system. I was thinking about whether to expose this as a boolean, but opted for an enum instead, as I have the suspicion other tweaks like this might be a added later on, in which case we extend this setting instead of having to add yet another one. Also, let's add some documentation for the GC logic.
Diffstat (limited to 'src/core/unit.h')
-rw-r--r--src/core/unit.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/unit.h b/src/core/unit.h
index b0df341a03..03dd88dcca 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -45,6 +45,13 @@ typedef enum KillOperation {
_KILL_OPERATION_INVALID = -1
} KillOperation;
+typedef enum CollectMode {
+ COLLECT_INACTIVE,
+ COLLECT_INACTIVE_OR_FAILED,
+ _COLLECT_MODE_MAX,
+ _COLLECT_MODE_INVALID = -1,
+} CollectMode;
+
static inline bool UNIT_IS_ACTIVE_OR_RELOADING(UnitActiveState t) {
return IN_SET(t, UNIT_ACTIVE, UNIT_RELOADING);
}
@@ -282,6 +289,9 @@ struct Unit {
/* How to start OnFailure units */
JobMode on_failure_job_mode;
+ /* Tweaking the GC logic */
+ CollectMode collect_mode;
+
/* The current invocation ID */
sd_id128_t invocation_id;
char invocation_id_string[SD_ID128_STRING_MAX]; /* useful when logging */
@@ -773,3 +783,6 @@ void unit_unlink_state_files(Unit *u);
#define LOG_UNIT_MESSAGE(unit, fmt, ...) "MESSAGE=%s: " fmt, (unit)->id, ##__VA_ARGS__
#define LOG_UNIT_ID(unit) (unit)->manager->unit_log_format_string, (unit)->id
#define LOG_UNIT_INVOCATION_ID(unit) (unit)->manager->invocation_log_format_string, (unit)->invocation_id_string
+
+const char* collect_mode_to_string(CollectMode m) _const_;
+CollectMode collect_mode_from_string(const char *s) _pure_;