For Programmers: Free Programming Magazines  


Home > Archive > PERL POE > December 2007 > Advice on POE and Daemons









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Advice on POE and Daemons
ty

2007-12-08, 8:27 am

I was looking to turn some of the servers I have written in POE into
daemons that would be run as non-root users because I do not have root
permissions on the machine they will run on. Could anyone share their
experience of creating daemons with POE? How have you handled
ensuring the server is always running? How do you recover from a
crash? Have you added any logging to your daemon?

Best Regards

Ty

Alex _

2007-12-09, 10:38 pm

you can run them as non-daemons using this.

http://www.plope.com/software/supervisor2/


ty <tvmaly@gmail.com> wrote: I was looking to turn some of the servers I have written in POE into
daemons that would be run as non-root users because I do not have root
permissions on the machine they will run on. Could anyone share their
experience of creating daemons with POE? How have you handled
ensuring the server is always running? How do you recover from a
crash? Have you added any logging to your daemon?

Best Regards

Ty



Wiggins d'Anconia

2007-12-14, 7:35 pm

ty wrote:
> I was looking to turn some of the servers I have written in POE into
> daemons that would be run as non-root users because I do not have root
> permissions on the machine they will run on. Could anyone share their
> experience of creating daemons with POE? How have you handled
> ensuring the server is always running? How do you recover from a
> crash? Have you added any logging to your daemon?
>
> Best Regards
>
> Ty
>


See Proc::Daemon::Init for daemonizing any long running Perl app. For
our app we used Log::Log4perl for logging, worked incredibly well. We
used external processes for checking pids and/or built in a way to talk
to the server via a socket to confirm things were still running well. As
for crash recovery, I'm a big fan of manual crash recovery cause I just
don't think you can write a technically sophisticated process, otherwise
you would have prevented the crash to begin with....

HTH,

http://danconia.org
ty

2007-12-14, 7:35 pm

I was looking for something pure perl. Do you know of anything that
would fit this?

On Dec 9, 9:18 pm, a...@ameritech.net (Alex _) wrote:
> you can run them as non-daemons using this.
>
> http://www.plope.com/software/supervisor2/
>
> ty <tvm...@gmail.com> wrote: I was looking to turn some of the servers I have written in POE into
>
> daemons that would be run as non-root users because I do not have root
> permissions on the machine they will run on. Could anyone share their
> experience of creating daemons with POE? How have you handled
> ensuring the server is always running? How do you recover from a
> crash? Have you added any logging to your daemon?
>
> Best Regards
>
> Ty


abhishek jain

2007-12-15, 7:31 pm

may be daemontool may be a goof crash recovery tool,
I havent used it on POE though but other perl applications run beautifully ,
Also not sure abt the non-root privileges but daemontools worth a try
http://cr.yp.to/daemontools.html
abhi



On 12/14/07, ty <tvmaly@gmail.com> wrote:
>
> I was looking for something pure perl. Do you know of anything that
> would fit this?
>
> On Dec 9, 9:18 pm, a...@ameritech.net (Alex _) wrote:
> have written in POE into
>
>


hideo

2007-12-15, 7:31 pm

ty (Fri 12/07/07 14:57):
> I was looking to turn some of the servers I have written in POE into
> daemons that would be run as non-root users because I do not have root
> permissions on the machine they will run on. Could anyone share their
> experience of creating daemons with POE? How have you handled
> ensuring the server is always running? How do you recover from a
> crash? Have you added any logging to your daemon?


We run several different daemons using POE. For the daemon I've always
used Net::Server::Daemonize. Very stable and easy to use:

daemonize(user => group => /path/to/pid);
# daemon code below

If you search the list you'll find that some have experienced buggy
behavior using Proc::Daemon and POE.

For logs I use Logfile::Rotate. Whichever event does the logging also
checks if it's time to rotate, e.g. at midnight:

# check if it's time to rotate the log first
if( (exists $h->{last_hour}) && ($hr < $h->{last_hour})){
if(close $h->{log}){
my $log = new Logfile::Rotate(
File => $h->{log_file},
Gzip => '/bin/gzip',
Dir => $h->{log_dir},
Flock => 'yes',
Persist => 'yes');
$log->rotate;
}
else{
$k->post(@{$h->{error_session}},
"Failed to close log file $h->{log_file} for rotation: $!")
}
}
$h->{last_hour} = $hr;

# open if necessary and print your log message

Ensuring that it's running would be done the same way that you make sure
any other daemon, e.g. apache, sendmail, etc., are running. All of ours
have standard start up scripts. We monitor them indirectly via what
tasks they're supposed to be doing. There are certainly more
sophisticated ways of monitoring status but this suffices.

Recovering from a crash depends entirely on what your daemon is doing.
It's possible you'll only need to restart it, or it may be a bit more
complicated than that. For example, we have a daemon that recovers
jobs it was running after a crash.


Cheers,
Zach
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com