It does not work as well. To re-create the issue:
git clone https://github.com/dbruno74/test-apps.git
cd tests-apps.git
snapcraft --destructive-mode
snap install test-apps_0.1_amd64.snap --dangerous
Look at snap/snapcraft.yaml and notice the “after” keyword. Relevant code here:
apps:
test-apps:
command: test-apps.sh
hello:
command: hello.sh
adaemon:
command: adaemon.sh
daemon: simple
after:
- oneshotdaemon
oneshotdaemon:
command: oneshotdaemon.sh
daemon: oneshot
Then open a second terminal and start snap log
snap logs test-apps -f
In the first terminal stop and restart:
snap stop test-apps && snap start test-apps
Printouts on the second terminal:
2020-11-12T12:38:40Z test-apps.adaemon[273030]: adaemon is running
2020-11-12T12:38:43Z test-apps.adaemon[273030]: adaemon is running
2020-11-12T12:38:44Z systemd[1]: Stopping Service for snap application test-apps.adaemon...
2020-11-12T12:38:44Z systemd[1]: snap.test-apps.adaemon.service: Succeeded.
2020-11-12T12:38:44Z systemd[1]: Stopped Service for snap application test-apps.adaemon.
2020-11-12T12:38:44Z systemd[1]: Started Service for snap application test-apps.adaemon.
2020-11-12T12:38:44Z systemd[1]: Starting Service for snap application test-apps.oneshotdaemon...
2020-11-12T12:38:44Z test-apps.adaemon[273434]: adaemon is running
2020-11-12T12:38:44Z test-apps.oneshotdaemon[273435]: oneshotdaemon ran
2020-11-12T12:38:44Z systemd[1]: snap.test-apps.oneshotdaemon.service: Succeeded.
2020-11-12T12:38:44Z systemd[1]: Finished Service for snap application test-apps.oneshotdaemon.
2020-11-12T12:38:47Z test-apps.adaemon[273434]: adaemon is running
2020-11-12T12:38:50Z test-apps.adaemon[273434]: adaemon is running
As you can see, adaemon is always started first.