diff options
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/platform.js')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/platform.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/platform.js b/packages/meshbay-hub/src/meshbay_hub/static/platform.js index a8e17bf..30df80e 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/platform.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/platform.js @@ -241,6 +241,28 @@ export const node = { async setPairingCode(code) { return bridge && bridge.node ? bridge.node.setPairingCode(code) : false; }, + /** + * The systemd unit's own state — start, stop and restart the node as a + * service, independent of whether the daemon itself is answering. Absent + * in a browser, same as the rest of `node`. + */ + service: { + available: Boolean(bridge && bridge.node && bridge.node.service), + async status() { + if (!bridge || !bridge.node || !bridge.node.service) return { supported: false }; + return bridge.node.service.status(); + }, + async stop() { + if (!bridge || !bridge.node || !bridge.node.service) + throw new Error('Node bridge not available'); + return bridge.node.service.stop(); + }, + async restart() { + if (!bridge || !bridge.node || !bridge.node.service) + throw new Error('Node bridge not available'); + return bridge.node.service.restart(); + }, + }, }; /** |