knew i should have put a disclaimer in.... woe is it that i can't edit my root node.

Warning: sorta rantish, but only because of the recent threads about Style and Changes in programming habbits.

the original is a patched Proc::Pid::File, i barely dream of CPANing a module, much less with a lower-case-top-level-name.

i'm just too lazy to think of a proper package name when i first need to make sure i'm not borking the whole concept.

my private modules live in namespaces like 'W' and 'Q' because i use them often from one-liners and typing "-MWunderbar::Blat::Bonk -e '$wunderbar = Wunderbar::Blat::Bonk->new or die;..." quickly becomes a pain. i know people who log into a slowish web page with obnoxiously short inactivity timeouts *chuckle* to block an evil-doer when they could just do:

$ blocker --ip <ip> [--case <case>] [--note <note>] [--unblock] # but this gives me more satisfaction. $ perl -MBlock -e 'block @ARGV' <ip> <case> <note>

i usually have to do several ':%s/$scn/$long_descriptive_name/g' before cut-n-pasting a tested section of code here at the monastery.

my daemons still being tested likewise live in /W because i'm to lazy to type /usr/site/app/version/bin/script check. when they're proven for a time and have the bells and whistles to make them usable by anyone but me, then they get big_long_descriptive_to_the_nth_degree_names, get put in rc.local, get their logs rotated, get rdisted ...

now if i could just figure out a good way to document that one script that saves me an hour easily every time i use it and always DWIM, but nobody else can quite get the hang of it...

$ ./cfg d1 I standby 12345678901 foo-6000-1 12 J 15 M12345678V 9876543 +2101 25 baz-6000-1-1 26 baz-6000-2-1 esp foo-6000-2 foo-6000-3 ### # outputs hundreds of lines of configuration commands # for backend systems that don't have scripting native # to their CLI ### if the others are lucky, they cut-n-paste-n-modify some snippets: $ perl -e 'for(1..48){printf"somecmd %s $_ X0000000%02X auto$/","foo-6 +000-1",$_' | backend

and i can't think of a good way to describe how each argument type is uniqely regexable and a configuration stack is updated when configuration things are given, and actions take place at the last possible moment using the top configuration stack entry when triggered by the next action thing given... but i still like that script more than the ones that give screens of --help information and get used by everybody.

anyways, that was an early era script, and my early era daemons used a ugly hack for quick and dirty daemonization with frills.

use lib qw( /Q/perl ); package Watcher; use Net::Server; our (@ISA); @ISA = qw/Net::Server/; Watcher->run( log_level => 5, log_file => 'watcher.log', pid_file => 'watcher.pid', background => 1, ); sub post_configure_hook { my $s = shift; $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = sub { $s->server_close; }; $SIG{HUP} = sub { $s->sig_hup; }; my $done = 0; while (!done) { # work } $s->server_close; }

worked ok, sorta ugly.

the latest version of this uses Config::General for general configuration (overrideable with Getopt::Long command line options), Log::Log4perl (modifying logging while daemon is running is so cool.), Proc::Daemon (but i want to have the parent hang around long enough to verify the daemon is alive, so i'll have to re-wheel or maybe just stick another fork in there somewhere), and a patched Proc::PID::File.

Proc::PID::File gets replaced. by something that DWIM with as short a name as i can manage (not as important when it's stable and you only have to type it once per script), and last but not least Pod2Usage for the docs.

so, review 'package pidfile;' =~ s/pidfile/Some::Longer::Name/; so i can ask about 'package Proc::Daemon::Wrangler::ThingAMaBob;' =p


In reply to Re^4: do i grok pidfiles? by zengargoyle
in thread do i grok pidfiles? by zengargoyle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.