Main: Notify systemd about being ready after writing to the output path via sd_notify

When running in a systemd service with the --idle flag we
want to have systemd's service dependency chain depend on
the templated secret file being written to the output path.
This commit is contained in:
networkException 2024-09-12 03:30:14 +02:00
parent 9716019cfb
commit f00b7d0133
Signed by: networkException
GPG key ID: E3877443AE684391

View file

@ -6,6 +6,7 @@ use std::thread;
use anyhow::Result;
use clap::Parser;
use sd_notify::NotifyState;
use serde_json::{Map, Value};
use url_escape;
@ -98,6 +99,8 @@ fn main() -> Result<()> {
fs::write(&output_path, output)
.expect(format!("To be able to write to '{}'", output_path.to_string_lossy()).as_str());
sd_notify::notify(true, &[NotifyState::Ready])?;
if idle {
loop {
thread::park();