daemon in perl

daemon in perl

am 26.10.2007 07:27:50 von kaustabh.banerjee

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..

Re: daemon in perl

am 26.10.2007 09:09:17 von Josef Moellers

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öllers (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

Re: daemon in perl

am 26.10.2007 13:13:41 von Ted Zlatanov

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

Re: daemon in perl

am 26.10.2007 18:05:55 von xhoster

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.

Re: daemon in perl

am 26.10.2007 18:16:08 von Petr Vileta

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.)