gismo141 / homebridge-server

Server plugin for homebridge
https://gismo141.github.io/configure-your-homebridge-2/
152 stars 20 forks source link

restart not working (Mac launchd) #59

Closed ifunlisted closed 5 years ago

ifunlisted commented 6 years ago

I'm using... "restart" : "launchctl unload ~/Library/LaunchAgents/com.homebridge.server.plist && launchctl load ~/Library/LaunchAgents/com.homebridge.server.plist" ...for restart in config.json, but it doesn't seem to be working. It does work in Terminal.

When I use the Restart button on the web ui, it appears to unload fine, but then never reloads.

I'm running on a Mac, using launchd

mbbeaubi commented 5 years ago

Faced the same issue. I think the problem is with the usage of the node.js exec method in the code. Not a node.js expert, but this method seems to terminate the underlying command execution when the node.js server shuts down. So the first part of the command executes, shuts down the node.js server, then the second part doesn't execute.

Figured out a simple workaround. Create a script, restart.sh with contents:

`#!/bin/sh

launchctl unload ~/Library/LaunchAgents/com.homebridge.server.plist && launchctl load ~/Library/LaunchAgents/com.homebridge.server.plist `

Then set the restart command to ~/.homebridge/restart.sh &

gismo141 commented 5 years ago

Thats true, I'll change the wiki accordingly.

gismo141 commented 5 years ago

Fixed by https://github.com/gismo141/homebridge-server/wiki/Usage#launchd