Command line interface to manipulate services

Necrobumping an old topic.

Both sockets and timers are in snapd now, but are not visible in snap services output, nor can be manipulated using snap(-ctl) <start|stop|restart> command.

I tried to experiment with this a bit and ended up with something like this:

$ snap services
Service                                       Startup   Current
lxd.activate                                  enabled   inactive
lxd.daemon                                    enabled   inactive
lxd.daemon.unix.socket                        enabled   active
test-snapd-timer-service.random-timer         disabled  inactive
test-snapd-timer-service.random-timer.timer   enabled   active
test-snapd-timer-service.regular-timer        disabled  inactive
test-snapd-timer-service.regular-timer.timer  enabled   active

Sockets end up with <socket-name>.socket suffix, while timers (there is only one per service), are suffixed with .timer.

The the manipulation could be done like this:

# stop the socket
$ snap stop lxd.daemon.unix.socket
# start the service
$ snap stop lxd.daemon.unix
# start the timer
$ snap start test-snapd-timer-service.regular-timer.timer
# logs of the timer (i.e. when it fired)
$ snap logs test-snapd-timer-service.regular-timer.timer

No need for extra --timer|--socket switches. One can just copy & paste the service/socket/timer name.

I already have some changes and can propose a branch. I’m open to suggestions.