Easy way to daemonize a POE script?
Hi, I've written a server application using POE which is working pretty well now. It's preforking some processes and then listens on a TCP port to acceppt client request. Now I'd like to run it independently, so my question is, is there an easy way for me to run a POE script daemonized (w/o having to use Unix backgrounding/forking)? Any hint is greatly appreciated. Thanks Winni
Re: Easy way to daemonize a POE script?
I've successfully used Net::Server::Daemonize to accomplish what you're after. shawn.c.carr...@gmail.com Perl Programmer Soccer Referee On Wed, Mar 10, 2010 at 10:18, Winfried Neessen nees...@cleverbridge.com wrote: Hi, I've written a server application using POE which is working pretty well now. It's preforking some processes and then listens on a TCP port to acceppt client request. Now I'd like to run it independently, so my question is, is there an easy way for me to run a POE script daemonized (w/o having to use Unix backgrounding/forking)? Any hint is greatly appreciated. Thanks Winni
Re: Easy way to daemonize a POE script?
Winfried Neessen wrote: Hi, I've written a server application using POE which is working pretty well now. It's preforking some processes and then listens on a TCP port to acceppt client request. Now I'd like to run it independently, so my question is, is there an easy way for me to run a POE script daemonized (w/o having to use Unix backgrounding/forking)? Any hint is greatly appreciated. Thanks Winni Hello, There are several ways you can accomplish this. I've been using Net::Server::Daemonize in $work code to good results. There's other modules floating around in the CPAN - all you need to do is a quick search of daemon and search.cpan.org turns up 123 results! However, one gotcha about using those daemonize modules is that you better wrap it in a BEGIN block so you are daemonized *before* you fire up POE or weird things will happen ( in my case heh ) ~Apocalypse
Re: Easy way to daemonize a POE script?
On 10 March 2010 18:02, Bruce Ferrell bferr...@baywinds.org wrote: On 03/10/2010 08:24 AM, p...@0ne.us wrote: Winfried Neessen wrote: Now I'd like to run it independently, so my question is, is there an easy way for me to run a POE script daemonized (w/o having to use Unix backgrounding/forking)? Below is the code I use. It's a slightly modified version I found when I googled for Perl daemon No no. This is not the approach. You're WRITING THIS CODE YOURSELF RATHER THAN USING A CPAN MODULE. I hope you have lots of tests for this wheel... BTW, I'd need a copy of Stevens handy to be sure, but I recall that the canonical unix daemonisation dance goes: double fork close standard file descriptors become session leader (POSIX::setsid IIRC) become process group leader (POSIX::setpgrp IIRC) set signal mask to ignore SIGHUP change working dir to root set file creation mask (umask) drop privileges I might well be missing a step. I think you did, too, though. /joel
Re: Easy way to daemonize a POE script?
On 03/10/2010 10:17 AM, Joel Bernstein wrote: On 10 March 2010 18:02, Bruce Ferrell bferr...@baywinds.org wrote: On 03/10/2010 08:24 AM, p...@0ne.us wrote: Winfried Neessen wrote: Now I'd like to run it independently, so my question is, is there an easy way for me to run a POE script daemonized (w/o having to use Unix backgrounding/forking)? Below is the code I use. Â It's a slightly modified version I found when I googled for Perl daemon No no. This is not the approach. You're WRITING THIS CODE YOURSELF RATHER THAN USING A CPAN MODULE. I hope you have lots of tests for this wheel... BTW, I'd need a copy of Stevens handy to be sure, but I recall that the canonical unix daemonisation dance goes: double fork close standard file descriptors become session leader (POSIX::setsid IIRC) become process group leader (POSIX::setpgrp IIRC) set signal mask to ignore SIGHUP change working dir to root set file creation mask (umask) drop privileges I might well be missing a step. I think you did, too, though. /joel Been working several years now and like I say I got it straight off a perl.org tutorial
Re: Easy way to daemonize a POE script?
2010/3/10 Winfried Neessen nees...@cleverbridge.com Now I'd like to run it independently, so my question is, is there an easy way for me to run a POE script daemonized (w/o having to use Unix backgrounding/forking)? You'll of course have to use that. But use CPAN packages. I've used Proc::Daemon successfully with a POE application. But I recommend to deamonize before starting the POE loop. Olivier.