On Fri, 2002-04-19 at 11:53, drieux wrote:
> 
> On Friday, April 19, 2002, at 07:03 , Chas Owens wrote:
> 
> > On Thu, 2002-04-18 at 18:28, drieux wrote:
> [..]
> >> you might want to have your 'main loop' in
> >>
> >> our $still_going = 1;
> >> $SIG{TERM} = sub { $still_going = 0 }; # correcting Chas's Issues... 8-)
> >> while ( $still_going ) {
> >>    # the main loop
> >> }
> [..]
> >
> > What issues? I use
> >
> > my $terminate = 0;
> > $SIG{TERM} = sub { $terminate = 1 };
> > until ($terminate) {
> >     #do stuff
> > }
> >
> > #cleanup
> 
> There it is... you use the 'until foo' - I lost track
> of the 'loop' - and so it looked 'insane' to me that
> the cool oneline sig handler was back end yakward...
> 
> besides - while($still_going) is up beat, positive, friendly,
> warm, HappyFluffyBunnies......
> 
> whereas - until($terminate) - downer, bummer, badly dressed
> cyborgs from the future hunting down the terran infestation units...
> 
> Therapy.... Seek Therapy.... 8-)

Some people believe that the glass is half empty and some believe the
glass is half full, but I believe some moth******er drank half my
fu***** Dr Pepper!

> 
> [..]
> 
> You do get points for remembering to have a 'shutdown' fail safe
> solution - but that should be the last knife in your boot. If you
> put out a PID_FILE in /tmp - then its an if file exists read pid
> send sig, sleep $reasonable_time , check proc table, if still up
> - send hard KILL.
> 
> > <example name="shutdown">
> > #!/bin/sh
> > PID=`ps -ef | grep daemon.pl | grep "/usr/bin/perl" | awk -e '{print
> > $2}'`
> 
> yes, yes, yes.... I know that this is not
> 
>       comp.oldGuys.shell
> 
> but two pieces of advice:
> 
> 1) always run your daemons under a 'special UID' so that
> you can use your os's version of
> 
>       ps -u $UID_FOR_ME | awk '/<pattern>/ {print $1}'

Yep, that would work.  This is mark two of the script.  The first used
cut to grab the PID, but that failed when the pid was small so I threw
on the awk and didn't refactor the script.

> 
> { this form works on solaris, linux and darwin - and is
> more portable across the *nix space than ps -ef.... }

Never really had a problem with ps -ef, and I liked being able to tell
the production guys to ps -ef themseleves.

> 
> Also - for safety sake you should expect that PID will
> be in a 'list context' hence should cope with it in the
> 
>       for pid in $PID
>       do
>               # skank on the puppy
>       done
> 

Definitely a must if you want a bullet proof script.  See above and
below why I didn't care enough to make it bullet proof. 

> 2) and remember that awk does regex..... 

Probably should refactor the script, but failure to care and desire to
not have to test it again tickle my sense of (little 'l') laziness more
than my (big 'h') Hubris.

> and since you
> are firing up this with the intention of Doing it with
> perl why not DO Perl? Unless you were planning on the
> classic 'init script' - at which point - why not just
> do the classical and canonical????
<snip />

Little l laziness.  I needed to give the production guys something to
work with and didn't really care much.  The other reason is that this is
not a daemon we want to start up with the box.  On boot up we do a
manual inspection of the system and then kick of various daemons.  The
script could benefit from being more robust, but the need is small (for
me at least) and if they dont like it, well, they can put in a change
request <grin />.

> 
> this way if you want to grow out your verb list for things
> like reload, status, daemon_act_funky... you isolate those
> in their own 'functions'...... but the two canonicals ones
> that you will need start/stop are kosher....
> 
> extra credit to show the 'hey guys we can still get our
> perl init script to run with
> 
>       sh init_script start
> 
> ciao
> drieux
> 
> ---
> 
> Kids these days, no respect for their elders,
> no respect for tradition..... not like when I
> was growing up - we had the doors and dylan,
> and elders you just had to respect....
> 
> 8-)

Hey, I listen to Dylan (Blond On Blond rules), the Doors, et al. as well
and respect of (local) tradition is why it is two scripts.  That is the
way the old ksh+dbaccess+SPL version worked, so I put the same frontend
on my Perl version.  One of the tings I have learned the hard way is
that sometimes the best way shouldn't be used because it clashes with
the mediocre way and confuses people (consistency can be important so
long as it is not dangerous).

-- 
Today is Prickle-Prickle the 36th day of Discord in the YOLD 3168
Fnord.

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to