WebThingsIO / gateway

WebThings Gateway - a self-hosted web application for monitoring and controlling a building over the web
http://webthings.io/gateway
Mozilla Public License 2.0
2.62k stars 339 forks source link

[Snap] Implement restart API #3160

Open benfrancis opened 3 months ago

benfrancis commented 3 months ago

On other platforms it's possible for the gateway to restart itself as part of setup and update procedures. This includes both restarting the gateway application, and restarting the whole operating system.

E.g. see https://github.com/WebThingsIO/gateway/blob/master/src/platforms/linux-raspbian.ts#L595

benfrancis commented 1 month ago

Is this actually necessary if snapd automatically restarts things when needed? Regardless it would be useful to have an implementation of the restart API which can be consumed by the front end to remotely reboot the gateway (as the power settings add-on does when running on Raspbian),

dilyn-corner commented 1 month ago

snapd will reboot the system itself under certain update conditions, namely when core things like the kernel update (I believe it is all of the kernel, snapd, or the gadget update).

Just in case you want an update of your own snaps to reboot the system, I would probably create a post-refresh hook which ensures the update succeeded and then reboots the system.

Critically, the shutdown interface is now considered super-privileged; as such there's a bit more rigmarole to get it connected on Core.

benfrancis commented 4 weeks ago

OK, it sounds as though we may not actually need to expose an API for this to the front end for the use case of restarting after an upgrade. I'm therefore going to remove the 2.0 milestone from this one but keep the issue open because it would still be useful for add-ons, or to add a remote reboot feature to the front end.