From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1NlRbA-0007qw-9j for garchives@archives.gentoo.org; Sat, 27 Feb 2010 18:41:11 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 37F4DE078E; Sat, 27 Feb 2010 18:40:58 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id EFBBCE078E for ; Sat, 27 Feb 2010 18:40:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 9BEB41B40CF for ; Sat, 27 Feb 2010 18:40:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at gentoo.org X-Spam-Score: -3.384 X-Spam-Level: X-Spam-Status: No, score=-3.384 required=5.5 tests=[AWL=-0.785, BAYES_00=-2.599] Received: from smtp.gentoo.org ([127.0.0.1]) by localhost (smtp.gentoo.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id la14EEylxoV6 for ; Sat, 27 Feb 2010 18:40:50 +0000 (UTC) Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by smtp.gentoo.org (Postfix) with ESMTP id F00131B40CA for ; Sat, 27 Feb 2010 18:40:37 +0000 (UTC) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1NlRae-00005m-5I for gentoo-user@gentoo.org; Sat, 27 Feb 2010 19:40:36 +0100 Received: from c-98-215-178-110.hsd1.in.comcast.net ([98.215.178.110]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 27 Feb 2010 19:40:36 +0100 Received: from reader by c-98-215-178-110.hsd1.in.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 27 Feb 2010 19:40:36 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: gentoo-user@lists.gentoo.org From: Harry Putnam Subject: [gentoo-user] Re: [OT] attach a perl script to daemon services Date: Sat, 27 Feb 2010 12:40:17 -0600 Organization: Still searching... Message-ID: <87635ifrou.fsf@newsguy.com> References: <87tyt3g7rr.fsf@newsguy.com> <201002262222.08735.alan.mckinnon@gmail.com> <87d3zrfza4.fsf@newsguy.com> <201002270100.43223.alan.mckinnon@gmail.com> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: c-98-215-178-110.hsd1.in.comcast.net User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:kZpCYU1MslxxZt8dyEe/Kn9af3g= X-Archives-Salt: d7c8956b-9cba-4418-bb3f-e300b8091b50 X-Archives-Hash: 65ff8f3a6b5ba1fe8f9c44cf2b2871c3 Alan McKinnon writes: > On Friday 26 February 2010 23:44:03 Harry Putnam wrote: >> Where I'm weak is the part where the custom script checks if the >> daemon is running, before the script itself starts. That part would >> need to be something pretty fool proof... maybe just grep ps output >> for the daemon? > > Maybe I'm misunderstanding you, but I don't understand this approach. > > If the daemon is not running there's nothing in the fifo. Why got to all the > complexity of writing an independent program that checks if something is > running then does various actions? The script necessarily depends on the > daemon running so instead of checking if it is, simply have the daemon start > the script. No daemon running = no script launched = no complexity. In the back of my mind there was a reason on opensolaris, that the script would fail if the fifo was empty... Then once data comes the script isn't listening. Or syslog won't write or something similar. I also have an opensolaris box that will be using this same script. I don't want to back up and relocate all that right now... Not sure I have it remembered right either, it seems just easier to have the script check before trying to start (for portability). Solaris syslog can write to named pipes but no so readily as linux syslog. Not sure of the details now. > If I'm still off-bat and this approach cannot work for solid technical > reasons, then I'll go away and shut if if you say so :-) No, not off-base... thanks. The checking isn't so hard to figure anyway, but you didn't talk about the script having some kind of trap or something to cover unexpected kill or failure. Michael has covered that somewhat. Also I didn't think to search cpan for something that does what I want. That may turn up something I can just plug into. Michael Higgins writes: [...] > in my perl script: > > log_file=>'Sys::Syslog', pid_file=>'/var/run/evolone_agi.pid'; > > Sys::Syslog" is an interface to the UNIX syslog(3) program. > > from /etc/init.d/evolone_agi > > depend() { > need net asterisk postgresql-8.4 > } > > As for reading new information, there are a gazillion ways. Trap a > signal to reread the configs? > > reload() { > ebegin "Reloading evolone_agi configuration" > start-stop-daemon --signal 1 --pidfile /var/run/evolone_agi.pid > eend $? "Error reloading evolone_agi" > } Thanks ... good info. How does the script behave regarding what happens if it receives a sigINT or sigKILL, or some other way dies (even from an internal error)? Does it log to syslog? and notify sysadmin? I haven't had occasion to run into an `EXIT trap' in perl... but there must be such a thing.