send notification from one systemd unit to another with python?

I have a systemd unit ‘my-app’ that runs my main python app but I want it to auto-update when there is a new version on a remote server. The detection is watched by another python systemd unit (let’s call it "watch-app") on the same OS that performs checks, download and replace old files by the new ones, and would send a notification to ‘my-app’ so it can change its state to something like "ready-to-be-updated".

I am looking for at least the best strategy to perform this task. I found sdnotify but it doesn’t clearly explain how to receive a notification and I can’t find any tutorial for this.

Maybe I’m on the wrong way ? Any help would be greatly apreciated.
Thx

Asked By: 16ar

||

sdnotify is for a service to communicate with systemd about its states having changed (for example, depending on the Type= of service, when it’s finished starting).

If you want to exchange information between services, do it however you like; usually, UNIX domain sockets are an easy way, but dbus is a good method if you need service detection etc.

You’d let your watcher server simply call systemd to stop the affected service, then update its files, then call systemd again. No need to overcomplicate things!

Answered By: Marcus Müller
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.