Recommended way to run a small local watchdog service on StartOS?

Hello everyone,

since my NitroPC does not provide an auto restart after an power outage (that often happens in my region), I am working on a fully local unattended power outage solution for my StartOS server that runs on the NitroPC.

My concept is that during a power outage, an independent device on the local network disappears immediately because it is not connected to the UPS (with the UPS only the NitroPC / StartOS, another Debian Workstation and the router are connected).

Both Debian Workstation and the StartOS server should periodically check this device via HTTP.

If it remains unreachable for approximately three minutes, both systems should perform a clean shutdown while sufficient UPS capacity is still available (it usually last only for 5-10 minutes).

My question is therefore:

What is the recommended way to implement such a small watchdog on StartOS?
(The
Debian Workstation is able to restart itself after a power outage.)

I assume there are several possibilities, for example:

  • a small custom system service installed over SSH,

  • another supported mechanism that survives StartOS upgrades,

  • or packaging it as a custom service.

Which approach would you recommend?

My goal is maximum reliability and compatibility with future StartOS updates.

Thank you very much.

Hi

Nice setup. One thing to know upfront: StartOS services run inside containers, so a packaged service can watch for the outage but can’t shut the host down itself — the clean shutdown has to run on the host.

So the route that works here is a small script over SSH: curl your canary device on a loop, and after ~3 min unreachable, call a clean shutdown. Just note it lives on the host outside the packaged system, so it may not survive StartOS updates — worth re-checking after each upgrade.

One thing to watch: make sure the shutdown fires with margin. If the UPS only holds 5–10 min and you wait ~3 min to confirm, a graceful StartOS shutdown can itself take several minutes — leave room for it to finish before the battery dies.

1 Like

You may be interested in reading this pull request for StartOS: Add Network UPS Tools settings by BeeJoe · Pull Request #3317 · Start9Labs/start-technologies · GitHub

1 Like

have a look at Uptime Kuma on the main registry, it allows setting up ‘watchdogs’ for a variety of things, http requests, tcp pings, etc.

1 Like

Thanks, that was a useful suggestion. I have now upgraded my server to StartOS 0.4.0.1 and installed Uptime Kuma from the main registry.

My intended use case is slightly unusual: I have a Shelly Plug outside the UPS. If mains power fails, the Shelly becomes unreachable while my StartOS server, router, and other equipment continue running on the UPS. After the Shelly has been unreachable for about three minutes, I want StartOS to perform a clean shutdown.

Uptime Kuma appears well suited to detecting the Shelly going offline. The remaining question is how to trigger a proper StartOS host shutdown from that event. I do not want to use a generic Linux shutdown command if that could bypass StartOS’s orderly service shutdown procedure.

Do you know whether Uptime Kuma on StartOS 0.4 can trigger a host-level StartOS shutdown, directly or through a supported StartOS API/command? If not, I may still need a very small watchdog component for that final step.

[This answer was created with the help of ChatGPT]

Thanks, I read through the Network UPS Tools pull request. This looks very relevant, especially the work around ensuring that a host shutdown cleanly stops StartOS services first.

In my case there is one complication: my battery, APC Easy UPS BV1000, does not provide a USB/data interface, so StartOS cannot obtain battery or mains status directly from the UPS.

My current design therefore uses a Shelly Plug connected outside the UPS purely as a mains-power detector. The StartOS server remains powered by the UPS. If the Shelly becomes unreachable for about three minutes, I want the server to initiate an orderly StartOS shutdown.

I have now upgraded to StartOS 0.4.0.1 and also installed Uptime Kuma, which could potentially handle the detection part.

Is there already a supported way in StartOS 0.4.0.1 for a service or local watchdog to request a clean host shutdown through StartOS itself, rather than issuing a generic Linux shutdown command?

If such an interface exists, I think the combination of Shelly + Uptime Kuma (or a minimal watchdog) could solve my case without requiring a UPS with a data interface.

[This answer was created with the help of ChatGPT]

The short answer is no. There is not currently an easy supported way in StartOS for a service local watchdog to request a clean host shutdown through StartOS itself. It is possible to write cron scripts that can monitor conditions and issue stop commands to services (via start-cli) and even a Linux shutdown command.

I have created an admin tool for my personal usage that I can easily install / run via ssh on my StartOS servers. It provides a menu driven interface that allows me to install cron jobs easily that I use to automate backups, health checks, notifications and more. You may find it useful to look at it - it’s on Github and see how it works and adapt it for your use case. I expect over time some / much of this will become irrelevant as StartOS includes more features natively.

Thanks Jesse.

My ChatGPT looked through your admin tool and the current StartOS 0.4.0.x CLI documentation.
It can see that start-cli package stop <ID> is available, while there does not appear to be a supported start-cli host-shutdown command.

For a local unattended power-failure watchdog running on the StartOS host, what exact sequence would you recommend before issuing the Linux shutdown?

In particular:

  1. Would you enumerate all running StartOS services and call start-cli package stop <ID> for each of them, or is there a better way to stop StartOS services in the correct dependency/order?

  2. Can those package stop commands be executed reliably from a root cron job without an interactive start-cli login/session? If authentication is required, what is the appropriate way to provide it for an unattended local script?

  3. After the services have stopped, would you simply use the normal Linux shutdown/poweroff command?

I want to keep this watchdog entirely local on the StartOS server and as small as possible, rather than giving another machine general SSH/admin access.

[This answer was created with the help of ChatGPT, finetuned by me.]

In general, I think if you did a normal Linux shutdown, it should shut down all of the containers for all the StartOS services relatively cleanly. But this is one that’s definitely better answered by a StartOS core developer who could answer authoritatively on this.

If I were doing it, I would probably loop through all of the packages and use start CLI package stop to request each of them to stop. Then loop and continue to check, waiting for them to actually stop and confirm that they’re stopped. And then use the normal Linux shutdown command. This will clearly need to be a program that is installed on StartOS. It would need to be installed in a way that it survives restarts. And you would need a way for this program to be triggered. I’m not sure how I would do that.

Given that there is an active pull request specifically related to UPS tools the best answer is probably to open an issue and request that your particular use case be considered as part of the release that includes these UPS tools.

Could you please send me the link to the active pull request related to UPS tools that you mentioned? I would like to review it before opening an issue, so I can first check whether my use case may already be covered.
And how to contact a start9 core dev?

Thanks!

Here is the pull request: https://github.com/Start9Labs/start-technologies/pull/3317

If you are interested in talking with the Start9 devs about the actual build, probably the best place to do that is at GitHub. Open a new issue, feature request, comment on one or even create a pull request of your own.

1 Like