Skip to content

Commit a80d2f9

Browse files
committed
fix: generator no longer emits version status line -- no notify socket in ExecStartPost
On Type=simple units failure is known; real-machine proof shows Type=notify is the same: systemd-notify reports "NOTIFY_SOCKET was not set", the control process exits 1, systemd then kills the just-started main process, all connections drop, and the service crash-loops. zenoh and cloudflared-main both died this way. The status line is a nice-to-have; the version number is trivially available via `<binary> -V`, so the drop-in no longer plays this trick.
1 parent 689a803 commit a80d2f9

1 file changed

Lines changed: 14 additions & 19 deletions

File tree

‎bin/shellflow/src/unit.rs‎

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,12 @@ pub(crate) fn render(manifest: &ServiceManifest, credential_keys: &[String]) ->
101101
));
102102
}
103103

104-
// The version status line. Only a notify unit can report: on a
105-
// `Type=simple` unit there is no notify socket, the call fails, and a
106-
// failing `ExecStartPost` takes the service down with it.
107-
if manifest.service_type == "notify" &&
108-
let Some(binary) = &manifest.binary
109-
{
110-
text.push_str(&format!(
111-
"ExecStartPost=/bin/sh -c 'systemd-notify --status=\"Version: $({binary} -V 2>&1)\"'\n"
112-
));
113-
}
104+
// No version status line: reporting it needs `systemd-notify`, and the
105+
// notify socket is not there for an `ExecStartPost` -- not on a
106+
// `Type=simple` unit and, as a live deploy proved, not on a `Type=notify`
107+
// unit either. The call fails, and a failing control process takes the
108+
// just-started service down with it. The version stays one command away
109+
// (`<binary> -V`); the drop-in does not try to be clever.
114110

115111
RenderedUnit { text, credential_keys: keys }
116112
}
@@ -156,20 +152,19 @@ mod tests {
156152
"{}",
157153
rendered.text
158154
);
159-
assert!(
160-
rendered.text.contains("systemd-notify --status=\"Version: $(/opt/dufs/bin/dufs -V"),
161-
"{}",
162-
rendered.text
163-
);
155+
assert!(!rendered.text.contains("ExecStartPost"), "{}", rendered.text);
164156
}
165157

166158
#[test]
167-
fn a_simple_unit_does_not_report_its_version() {
168-
// A `Type=simple` unit has no notify socket: the status call fails,
169-
// and a failing `ExecStartPost` takes the service down with it.
159+
fn no_unit_reports_its_version_through_the_dropin() {
160+
// Reporting needs `systemd-notify`, and the notify socket is not
161+
// there for an `ExecStartPost` -- a live deploy proved it fails on a
162+
// `Type=notify` unit too, and a failing control process takes the
163+
// just-started service down with it.
170164
let manifest = manifest(
171165
"host = \"api\"\nunit = \"dufs.service\"\n\
172-
binary = \"/opt/dufs/bin/dufs\"\n",
166+
binary = \"/opt/dufs/bin/dufs\"\n\
167+
type = \"notify\"\n",
173168
);
174169
let rendered = render(&manifest, &[]);
175170
assert!(!rendered.text.contains("systemd-notify"), "{}", rendered.text);

0 commit comments

Comments
 (0)