How I can send systemd-notify

This is my app:

apps:
  notify-appication:
    daemon: notify
    install-mode: disable
    restart-delay: 1s
    restart-condition: always
    watchdog-timeout: 45s
    command-chain: &_command-chain
      - bin/wayland-launch
      - bin/dbus-launch
      - snap/command-chain/alsa-launch
    command: usr/bin/service-notify usr/bin/wrapper

and my usr/bin/service-notify

#!/usr/bin/env python3

import sdnotify
import time

notifier = sdnotify.SystemdNotifier()


def service_notify():
    """Send keep alive ping"""

    print("Send keep alive ping: READY")
    while True:
      notifier.notify("WATCHDOG=1")
      print("Send keep alive ping")
      time.sleep(20)

service_notify()

I received error Got notification message from PID 19833, but reception only permitted for main PID 19785

my guess would be the command-chain gets in your way here … i’d try to put the notification script first …

that said, if you want to use the watchdog i dont think you need to use daemon: notify at all … a daemon: simple plus watchdog-timeout: should be enough to have systemd handle all this internally …

OK, thanks… I will try it

I put on the first notification script but I received the same

I understood what the problem is, but I don’t know how to fix it. For some reason, it runs bin/dbus-launch first … any ideas?

snap.aps-firmware-3.daemon.service - Service for snap application aps-firmware-3.daemon
     Loaded: loaded (/etc/systemd/system/snap.aps-firmware-3.daemon.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-06-13 16:25:15 UTC; 6s ago
   Main PID: 85106 (dbus-launch)
      Tasks: 86 (limit: 9188)
     CGroup: /system.slice/snap.aps-firmware-3.daemon.service
             ├─85106 /bin/sh /snap/aps-firmware-3/x1/bin/dbus-launch /snap/aps-firmware-3/x1/snap/command-chain/alsa-launch /snap/aps-firmware-3/x1/usr/bin/wrapper