gismo141 / homebridge-server

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

cannot load (or find) log file #15

Closed farstreet closed 7 years ago

farstreet commented 7 years ago

I cannot load the log file through the webpage. /showLog eventually times out.

At first I thought I just had to specify a logfile path and location for the homebridge-server plugin, afterwards I realized that I was maybe supposed to link to the actual log file of homebridge. But when I then tried to find how that file should be named, I couldn't find it back. I then tried to look for files that could look like they were the log files, but no luck again neither.

I am running homebridge on OSX, automatically starting it with Launchd as explained on https://github.com/nfarina/homebridge/wiki/Install-Homebridge-on-OSX

Pretty sure it's something stupid, but just can't find it right now...

Thanks, Jurgen

gismo141 commented 7 years ago

Hi @farstreet Jurgen!

At the moment I haven't implemented journalctl-logging yet. Have you added something to the com.homebridge.server.plist?

But yes in theory the standard logging works as follows (because Homebridge doesn't support it by itself 👎 ):

  1. I take the normal output to the console,
  2. pipe it to a file,
  3. read the file by the server and
  4. present it to the user on a webpage.

So the fact that is important is the pipe to a file, not quite sure how to do that in the *.plist-file but I am pretty sure, that macOS is supporting logs for launchctl.

I'll have a look at it and I'll keep you posted for updates!

farstreet commented 7 years ago

They might actually not anymore. Seems like I'll have to go for another service that loads Homebridge automatically at boot or when the process gets killed for whatever reason.

Anything you suggest? Preferably documented somewhere as I realized how far away the stuff I learned in school is in my memory now.

gismo141 commented 7 years ago

Another option might be to use an Automator program! Just:

  1. open Automator.app (preinstalled on every macOS),
  2. create a new program,
  3. Add the Execute Shell Script and
  4. write something like in the picture.

homebridge as automator program

To copy-paste you can use:

export PATH=$PATH:/usr/local/bin/ 
/usr/local/bin/homebridge -D -U ~/.homebridge > ~/.homebridge/output.log 2>&1 &

Finally add the ~/.homebridge/output.log to homebridge's config.json. Then you could add this new Automator program to your accounts login-items and it will automatically launch on every login :)

That is not as convenient in case of an automatic restart in any case of error, but in my opinion the error should always be investigated instead of ignored ;)

farstreet commented 7 years ago

Looks good. Trying it tonight :)

ageorgios commented 7 years ago

how to configure with journalctl?

gismo141 commented 7 years ago

@ageorgios See https://github.com/gismo141/homebridge-server/wiki/Usage#systemd on how to configure the plugin to use the journalctl-produced-log.

gismo141 commented 7 years ago

@farstreet I've now found a way to log with launchd!

See my hints at: https://github.com/gismo141/homebridge-server/wiki/Usage#launchd Please post here if you have any further questions about this topic.

farstreet commented 7 years ago

I'll try it. Thanks for the update!