<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family:Arial,Helvetica,sans-serif"></span><span style="font-family: Arial, Helvetica, sans-serif;">Hi Lennart,</span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<br>
</div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<div>> Can't you run your upgrade script in idempotent way as a helper<br>
<span>> </span>service that is pulled in by your main daemon and ordered before it,<br>
<span>> </span>but conditions itself out if it already did its job? that's usually<br>
<span>> </span>the most robust way, since then it's sufficient to just restart your<br>
<span>> </span>daemon or reboot, and everything will always catch up correctly.<br>
<br>
<span>> </span>i.e. if you have foo-daemon.socket + foo-daemon.service then define<br>
<span>> </span>foo-upgrade.service that is pulled in from foo-daemon.service via<br>
<span>> </span>`Wants=foo-upgrade.service` + `After=foo-upgrade.service`. And then<br>
<span>> </span>add `ConditionFileExists=!/some/touch/file` to `foo-upgrade.service` to<br>
<span>> </span>make it a NOP if things have already been updated, using a touch<br>
<span>> </span>file. (some better, smarter condition check might work as well, see<br>
<span>> </span>man pages of things systemd can check for you).<br>
</div>
<br>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-family: Arial, Helvetica, sans-serif;">That is a great pattern!</span></span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-family: Arial, Helvetica, sans-serif;"><br>
</span></span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-family: Arial, Helvetica, sans-serif;">A Type=oneshot seems useful for the upgrade process.<br>
</span></span></div>
<p><span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-family: Arial, Helvetica, sans-serif;">For the record, I have appended what ended up working.</span></span></p>
<br>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-family: Arial, Helvetica, sans-serif;">Thanks!</span></span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-family: Arial, Helvetica, sans-serif;"><br>
</span></span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-family: Arial, Helvetica, sans-serif;">Cheers,</span></span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-family: Arial, Helvetica, sans-serif;">Klaus<br>
</span></span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<br>
</div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Arial, Helvetica, sans-serif;">---</span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br>
</span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Arial, Helvetica, sans-serif;">The following three unit files open a listening socket, run the myupgrade service,</span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Arial, Helvetica, sans-serif;">and only then start the /usr/bin/mydaemon service. The socket listens while the</span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Arial, Helvetica, sans-serif;">myupgrade service runs so that clients can connect. But the clients are queued</span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Arial, Helvetica, sans-serif;">until myupgrade has finished and /usr/bin/mydaemon starts accepting</span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Arial, Helvetica, sans-serif;">connections.<br>
</span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br>
</span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Calibri, Helvetica, sans-serif;">mydeamon.service:<br>
</span></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<div><span style="font-family: "Courier New", monospace;">[Unit]</span><br>
<span style="font-family: "Courier New", monospace;">Description=service that does something</span><br>
<span style="font-family: "Courier New", monospace;">After=mydaemon.socket</span><br>
<span style="font-family: "Courier New", monospace;">Requires=<span style="font-family: "Courier New", monospace;">mydaemon</span>.socket</span><br>
<span style="font-family: "Courier New", monospace;">After=myupgrade.service</span><br>
<span style="font-family: "Courier New", monospace;">Wants=myupgrade.service</span><br>
<span style="font-family: "Courier New", monospace;">[Install]</span><br>
<span style="font-family: "Courier New", monospace;">WantedBy=multi-user.target</span><br>
<span style="font-family: "Courier New", monospace;">[Service]</span><br>
<span style="font-family: "Courier New", monospace;">Type=simple</span><br>
<span style="font-family: "Courier New", monospace;">ExecStart=/usr/bin/mydaemon</span><br>
</div>
<div><br>
</div>
<div><span style="font-family: Calibri, Helvetica, sans-serif;">myupgrade.service:<br>
</span><span style="font-family: "Courier New", monospace;">[Unit]</span><br>
<span style="font-family: "Courier New", monospace;"></span>
<div><span style="font-family: "Courier New", monospace;">Description=service to run before mydaemon</span><br>
<span style="font-family: "Courier New", monospace;">[Service]</span><br>
<span style="font-family: "Courier New", monospace;">Type=oneshot</span><br>
<span style="font-family: "Courier New", monospace;">ExecStart=/usr/bin/bash -c "echo goodnight;sleep 60;echo goodmorning"</span><br>
<br>
</div>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><span style="font-family:Arial,Helvetica,sans-serif"></span>mydeamon.socket<br>
</div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<span style="font-family: Calibri, Helvetica, sans-serif;">
<div><span style="font-family: "Courier New", monospace;">[Unit]</span><br>
<span style="font-family: "Courier New", monospace;">Description=mydaemon listen socket</span><br>
<span style="font-family: "Courier New", monospace;">[Socket]</span><br>
<span style="font-family: "Courier New", monospace;">ListenStream=9999</span><br>
<span style="font-family: "Courier New", monospace;">[Install]</span><br>
<span style="font-family: "Courier New", monospace;">WantedBy=sockets.target</span></div>
<div><span style="font-family: "Courier New", monospace;"><br>
</span></div>
</span></div>
</div>
</div>
</body>
</html>