Re: Restarting a Perl-script (socket daemon) from /etc/inittab

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On 6/2/2011 2:46 PM, Alexander Farber wrote:
>
> The Perl server poll()s TCP-sockets and forks
> only once - at the startup by calling this method:
>
>      sub daemonize {
>          die "Can not fork: $!\n" unless defined (my $child = fork());
>          # the parent should die
>          exit 0 if $child;

[....]

> Since I'm tired of restarting the server manually,
> I've tried to add it to the /etc/inittab:
>
>      pref:3:respawn:/bin/su -c '/usr/local/pref/pref.pl' nobody
>
> (and I've added a nightly cronjob to
> "pkill pref.pl" in the hope to refresh perl this way).
>
> Unfortunately this does not work as expected -
> in the /var/log/messages I see that the script
> is being started again and again every 5 mins:
>
>      Jun  2 18:55:56 myhost init: Id "pref"
>      respawning too fast: disabled for 5 minutes
>
> What am I doing wrong here?

It needs to not fork/exit on its own if you want init to respawn when it 
exits.

-- 
  Les Mikesell
    lesmikesell@xxxxxxxxx

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux