Detect shutdown vs normal service stop?

Hello,

From the within service, how to detect that service is being terminated because of system shutdown/reboot vs regular service stop e.g. snap stop myapp? Under regular systemd setup, there is a file /run/nologin created during shutdown and service can check and make decision based on that. How is that under snap?

BR,

Solved the issue by using dbus monitor for reboot.target.

Added system dbus plug then registered a match.

Got on to the rake, my monitor was not giving errors but also was not receiving any dbus events until I added dbus-x11 dependency into my snapcraft.yaml.

BR,

1 Like