typicode / katon

(use hotel instead)
https://github.com/typicode/hotel
MIT License
683 stars 28 forks source link

katon install & status doesn't work in tmux #40

Open rstacruz opened 10 years ago

rstacruz commented 10 years ago

I installed it:

$ sudo katon install
Installing katon
Done

Typing katon status says that it's not installed: (trying this twice produces the same result

$ katon status
Checking that katon daemon is loaded...
OK
Checking .ka domain...
KO try `sudo katon install`

I tried installing it again:

$ sudo katon install
Installing katon
katon.firewall: Already loaded
Done

Any tips on how to debug this? Katon 0.6.5, Node 0.10.32, OSX 10.9.5.

rstacruz commented 10 years ago

Adding some more debugging info.

netstats show nothing:

$ netstat -an | egrep "(31000|13375)"
# no results

Plist seems to be in place.

$ ls /Library/LaunchDaemons/katon.firewall.plist

katon start as a regular user doesn't work.

$ katon start
Starting katon daemon
Could not open job overrides database at: /private/var/db/launchd.db/com.apple.launchd/overrides.plist: 13: Permission denied
launch_msg(): Socket is not connected
Done

sometimes it says this:

$ katon start
Starting katon daemon

Error: EACCES, permission denied '/Users/rsc/Library/LaunchAgents/katon.plist'
    at Object.fs.openSync (fs.js:438:18)
    at Object.fs.writeFileSync (fs.js:977:15)
    at module.exports (/usr/local/lib/node_modules/katon/src/cli/utils/render.js:14:6)
rstacruz commented 10 years ago

Okay, I got this. I got 2 problems:

  1. /private/var/db/launchd.db/com.apple.launchd/overrides.plist was not accessible for my user. I remedied this by temporarily doing chmod a+rw on the file.
  2. launchctl load doesn't work in Tmux. This makes katon start fail when invoked inside Tmux. (http://apple.stackexchange.com/questions/41412/using-tmux-and-pbpaste-pbcopy-and-launchctl)

I recommend adding a check for start and status commands to look at process.env.TMUX. If the variable exists, exit and let the user know that katon should be invoked outside a tmux session.

rstacruz commented 10 years ago

The workaround is to use reattach-to-user-namespace to run katon: https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard

That is:

$ reattach-to-user-namespace katon start
$ sudo reattach-to-user-namespace katon install