I am currently working on snapping a software and I have a question about it. The software is composed of 2 executables, a launcher and the main app, a daemon. To snap them inside a unique snap I specify 2 apps in the snapcraft.yaml : launcher and daemon.
My question is: do I have to use the snapd-control interface to start/stop the daemon with the launcher ?
This would imply a manual verification to release the snap on the store.
As both apps are in the same snap, is there another way to start/stop one with the other ?
Right now I am using the devmode confinement so in the launcher code I explicitly wrote “snap start/stop daemon” and it works but when I switch the confinement to classic I can’t do that anymore.
i know you can use
snapctl stop/start from hooks to control a daemon in the same snap … i’m not sure you can use it from another app in the same snap (would be a subject to testing)…
snapctl works from apps as well as hooks
Okay, thank you.
I am trying to use snaptcl command thanks to its documentation but I struggle with it.
According to the documentation, I should create a task to start/stop an app but when I write
snapctl task start augmenta.daemon it returns
Unknow command "task" Please specify one command of: get, restart, services, set, start or stop
And when I write
snapctl start augmenta.daemon I got “cannot start without a context” error. I am not really sure what it means, could you explain me ?
What would be the correct syntax or process to start an app with the snapctl command ?
You do not need to verbatim specify
snapctl, so just use:
snapctl stop $SNAP_NAME.daemon
snapctl is meant for use inside snaps, while
snap is meant for use outside of snaps, so if you are testing out the commands from outside the snap, use
snap stop ..., while if you are inside the snap in an app or a hook, you would use
snapctl stop ... (or start…)
Okay, thank you for the clarification.
I did call
sudo snapctl start augmenta.daemon from the code in my app via
system() function (cpp) and got the same result with
cannot start without a context.
You shouldn’t be using
sudo inside the snap at all, can you try without
I tried and … it works ! I will keep the sudo out of my code, thank you