Support for snapctl stop/start/restart services

@ondra I presume when you say ‘from another service’ it means another service from with in the same snap right ? If that is the case , if there a way to control the start/stop/restart of a service of one snap from another snap ? Thanks.

So you will need to use content interface to create connection between snaps here so snapctl is executed in context of snap running those services. It’d break confinement if one can control services of different snap.

Of course ideal solution here would be interface allowing one snap altering configuration settings of another snap
Sort of light content share… restricted only to configuration settings/
Then you can just implement configure hook in receiving snap and snapctl set in client snap

@pstolowski do you know is there is something like this in works or in backlog?

Thanks, Could you elaborate this " snapctl is executed in context of snap running those services" this seems to be something I am exploring. I have a content interface between two of my snaps to share data already, so will I be able to control the consumer snap (with plugs defined) from my producer snap (with slots defined) with snapctl command ? To give a more precise explanation, here is what I am trying to do.

To restart SNAP-1 (Consumer) I can set a variable and config hook stops/starts the service depending on the value being set.

value=$(snapctl get mysnap-disable)
if [ "$value" = "true" ]; then
        snapctl stop --disable ${SNAP_NAME}.myser 2>&1 || true
        snapctl start --enable ${SNAP_NAME}.myser 2>&1 || true
        snapctl restart ${SNAP_NAME}.myser 2>&1 || true

And So I am trying to find a way to set this variable mysnap-disable from my producer snap (SNAP-2). Let me know if this is something that is feasible ?

At the moment we unfortunately don’t have interface for this, so I have opened forum post to discuss this in more generic way, feel free to contribute there:

configure hook code looks good, unfortunately I have not clean solution how to overcome this limitation