Redir 3 forwarded ports are not being cleared correctly
ethervoid opened this issue · 4 comments
Hi,
We've been experiencing problems with redir, version 3.1, not being cleared after a vagrant reload
I checked the code and found that is being done here.
The problem is that is getting the wrong PIDs from here
For example, my redir PID for port 3000 is 10459
but in the file redir_3000 is stored the PID 10456
I'm going to paste some outputs here:
ethervo+ 10459 0.0 0.0 6656 108 ? Ss 16:46 0:00 redir 127.0.0.1 3000 10.0.3.131 3000
and the file cat
cat /media/data/development/vm/cartodb_lxc_xenial/.vagrant/machines/default/lxc/pids/redir_3000.pid [16:47:18]
10456
It seems like this part is not returning a correct PID for that process
Looks like spawn could be returning the parent pid instead of the final one?
More info:
If you go to irb
and do:
irb(main):002:0> spawn 'redir 127.0.0.1:3000 10.0.3.131:3000 2>/dev/null'
=> 29411
but if you make a pgrep
you get
❯ pgrep redir [17:37:35]
29413
Looks like the problem is the child process detaching after daemonizing itself
Thanks for the detailed report. It turns out that "foreground mode" was the key. I've noticed that it was a new option compared to v2.x, so that was a hint... and it was it.
I've pushed a fix on master
. Could you try and confirm the fix?
Tested, seems to be working fine :) thank you