creativcoder / pywebsocket

Automatically exported from code.google.com/p/pywebsocket
0 stars 0 forks source link

Add command-line argument to run pywebsocket daemonized #85

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We use pywebsocket at Mozilla as part of our automated test infrastructure.  
When we run tests under gdb, pywebsocket captures ctrl+c's meant for the 
debugger and kills itself.

I have a simple patch which adds a command-line flag to ignore SIGINTs.  Would 
you be willing to take it?

Original issue reported on code.google.com by justin.l...@gmail.com on 9 Dec 2010 at 4:52

GoogleCodeExporter commented 9 years ago

Original comment by justin.l...@gmail.com on 9 Dec 2010 at 5:03

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry, not navigating this bug tracker too well.  Above is a patch.  :)

Original comment by justin.l...@gmail.com on 9 Dec 2010 at 5:03

GoogleCodeExporter commented 9 years ago
And here's the corresponding Mozilla bug:

https://bugzilla.mozilla.org/show_bug.cgi?id=613813

Original comment by justin.l...@gmail.com on 9 Dec 2010 at 5:04

GoogleCodeExporter commented 9 years ago
I understand what you need. But this sounds specific to your test suite 
architecture. For now, could you try having some stub python code that masks 
SIGINT on your side? Will this work for you?

e.g.

pywebsocket_ignore_sigint.py
====
import signal

from mod_pywebsocket.standalone import _main

if __name__ == '__main__':
  signal.signal(signal.SIGINT, signal.SIG_IGN)
  _main()
====

Original comment by tyoshino@chromium.org on 10 Dec 2010 at 6:41

GoogleCodeExporter commented 9 years ago
If I understand your problem correctly, it might solve the problem to have a 
functionality to launch a stand-alone server as a daemon process.

I think daemonization would be a valid feature request, and we probably should 
implement it.
(I think daemonization will only work on Unix (and will not on Windows), but I 
hope this limitation won't block your use cases)

Original comment by yutak@chromium.org on 10 Dec 2010 at 7:33

GoogleCodeExporter commented 9 years ago
> If I understand your problem correctly, it might solve the problem to have a 
> functionality to launch a stand-alone server as a daemon process.

Could you elaborate on this?  If it only works on *nix, that's fine with me.  :)

Original comment by justin.l...@gmail.com on 15 Dec 2010 at 12:14

GoogleCodeExporter commented 9 years ago
daemon() is basically a combination of fork and setsid. A daemon process is 
separated from its parent and belongs to a new process group, thus signals to 
the parent process will no longer reach the child (daemon) process.

I hope this clarifies your question.

Original comment by yutak@chromium.org on 15 Dec 2010 at 2:32

GoogleCodeExporter commented 9 years ago
Oh, I see.  Yes, I think daemon() would solve the problem.  In the meantime, 
we'll probably just use a wrapper script.

Original comment by justin.l...@gmail.com on 15 Dec 2010 at 9:16

GoogleCodeExporter commented 9 years ago

Original comment by tyoshino@chromium.org on 17 Dec 2010 at 4:47