gismo141 / homebridge-server

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

Reboot issue on MacOS #44

Closed senorshaun closed 5 years ago

senorshaun commented 7 years ago

Launching using a LaunchAgent in the auto-login user's Library. My reboot command is now just 'launchctl unload /Users/*/Library/LaunchAgents/*****.plist' because I'm just trying to get the single command to work. The page just spins but the plist is never unloaded. I wouldn't think I need to do any special permissioning as I am launch HomeBridge via the same launching account, an account that I can interactively unload the plist without any sudo necessary. Anyone see this on MacOS?

gismo141 commented 7 years ago

Hi @ZB370: I indeed have the same problem but at the moment I'm not quite sure what the reason might be. Maybe the homebridge is not allowed to execute launchctl-commands. At the moment that's just guessing.

mkellsy commented 7 years ago

You need to define full path to /bin/launchctl.

friko21 commented 7 years ago

I have the following command successfully working on Mac OS: /usr/bin/killall homebridge

mkellsy commented 7 years ago

launchd on MacOS doesn't have a restart option. You will have to create an sh script to do this. I tried but wasn't able to get a valid thing running.

Short of creating a "certified stack" for homebridge. I think this is not solvable using launchd on a Mac, until Apple adds restart functionality to their launchd.

The issue with running 2 commands is the first shuts down homebridge. This plugin is ran by homebridge. So since the first unload command shuts down the plugin, it can not call the second. You need something outside of the homebridge environment.

I found that using launchd on MacOS causes many instances of Homebridge to run. I had nothing but issues with keeping Homebridge linked to HomeKit because of this. This is why I started using Supervisord instead. Supervisord only runs one instance, and it keeps it alive.

Supervisord is a old very stable launch control system. It is used in many production enviornments, because it simply works. The cool thing about Supervisord is it will keep Homebridge running, and it will keep your Minecraft server running too.

Then you can combine this with https://www.npmjs.com/package/homebridge-cmdswitch2, and create switches in homebridge to control your Minecraft server.

So the reason why I wrote the README with Supervisord as the default is because it works.

gismo141 commented 5 years ago

Fixed with the new Wiki-page: https://github.com/gismo141/homebridge-server/wiki/Usage#launchd