For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > October 2007 > daemon in perl









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 daemon in perl
kaustabh.banerjee@gmail.com

2007-10-26, 4:23 am

I have a perl daemon which queries the DB in every 10 secs and checks
some data. The daemon runs fine for most of the time, but dies
sometimes with some DB exceptions. I have put eval block to survive
this.

But still it breaks sometimes.

How to survive any exception at all. I just want to run no matter
what..

Josef Moellers

2007-10-26, 4:23 am

kaustabh.banerjee@gmail.com wrote:
> I have a perl daemon which queries the DB in every 10 secs and checks
> some data. The daemon runs fine for most of the time, but dies
> sometimes with some DB exceptions. I have put eval block to survive
> this.
>=20
> But still it breaks sometimes.
>=20
> How to survive any exception at all. I just want to run no matter
> what..
>=20


There's a mis-spelt identifier in line 1234 of your program.

1. How on earth are we to know what your problem is if you don't show us =

any code?
2. Don't program around a problem, solve it.

--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html

Ted Zlatanov

2007-10-26, 8:04 am

On Thu, 25 Oct 2007 22:27:50 -0700 kaustabh.banerjee@gmail.com wrote:

kb> I have a perl daemon which queries the DB in every 10 secs and checks
kb> some data. The daemon runs fine for most of the time, but dies
kb> sometimes with some DB exceptions. I have put eval block to survive
kb> this.

kb> But still it breaks sometimes.

kb> How to survive any exception at all. I just want to run no matter
kb> what..

(you should really find and fix your bug, as Josef Moellers suggested)

Use fork() to start a copy of your program, then *in the copy* do the
dangerous work. Use IPC if the parent process must know what the child
is doing. Make sure you wait for the child process. See `perldoc -f
fork' and all the related documentation for more information.

Ted
xhoster@gmail.com

2007-10-26, 7:07 pm

kaustabh.banerjee@gmail.com wrote:
> I have a perl daemon which queries the DB in every 10 secs and checks
> some data. The daemon runs fine for most of the time, but dies
> sometimes with some DB exceptions. I have put eval block to survive
> this.
>
> But still it breaks sometimes.


Have you considered scotch tape? Or at least telling us what errors you
are getting?

>
> How to survive any exception at all. I just want to run no matter
> what..


If the database server is on fire, exactly what is the client supposed to
do? If you want your program to "run" no matter what, even if it doesn't
do anything useful, then replace all the code with "sleep while 1"

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
Petr Vileta

2007-10-26, 10:07 pm

kaustabh.banerjee@gmail.com wrote:
> I have a perl daemon which queries the DB in every 10 secs and checks
> some data. The daemon runs fine for most of the time, but dies
> sometimes with some DB exceptions. I have put eval block to survive
> this.
>
> But still it breaks sometimes.
>
> How to survive any exception at all. I just want to run no matter
> what..


Very simple. Instead of
$sth->execute() or die "error";
use some like this
$sth->execute() or errorhandler("error on line XY");
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)



Sponsored Links







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

Copyright 2008 codecomments.com