Thread View: news.software.nntp
10 messages
10 total messages
Started by Russ Allbery
Sat, 21 Mar 1998 00:00
Use of startup_innd.pl filter
Author: Russ Allbery
Date: Sat, 21 Mar 1998 00:00
Date: Sat, 21 Mar 1998 00:00
35 lines
2042 bytes
2042 bytes
When I first looked at the documentation of this, my thought was "cool, I
can save my cache of message IDs and my hash of rejecting MD5 signatures
when the server shuts down and reload them when the server restarts, and I
don't have to lose all my filter history." Then, reading the
documentation, I couldn't find any way to run something before the server
shuts down (with ctlinnd shutdown).
Am I missing something, or is there no way to use this to do what I want?
(I also fail to see the point of filter_after_reload. What does this gain
me over code in filter_innd.pl that isn't inside a sub and therefore runs
when the Perl script is loaded? I currently just have my statistics
dumping code in filter_innd.pl as:
# Since we've just been reloaded, let's write out some statistics.
if (defined $statfile) {
open (FILE, ">$statfile");
print FILE 'MD5 rejects: ' . (scalar keys %md5reject) . "\n";
print FILE 'HDR rejects: ' . (scalar keys %hashreject) . "\n";
print FILE 'MID history: ' . (scalar keys %rejecthistory) . "\n";
print FILE "\nRejecting MD5 hashes:\n";
for (keys %md5reject) { print FILE $md5reject{$_} . ' ' . $_ . "\n" }
print FILE "\nRejecting header hashes:\n";
for (keys %hashreject) { print FILE $hashreject{$_} . ' ' . $_ . "\n" }
close FILE;
}
and it works just fine; it writes out the statistics file every time
filter.perl is reloaded.)
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
Re: Use of startup_innd.pl filter
Author: Russ Allbery
Date: Sat, 21 Mar 1998 00:00
Date: Sat, 21 Mar 1998 00:00
29 lines
1534 bytes
1534 bytes
Jeremy <jeremy@exit109.com> writes:
> Well, startup_innd.pl is loaded and evaulated at startup. I don't like
> it though, because if you want to change anything it becomes a bit of a
> pain.
I somewhere got the impression that reloading filter.perl reloaded it, but
maybe I'm wrong.
> If you want something to run only at startup, you can do something like:
> if (not $already_running) {
> ...stuff...
> $already_running = 1;
> }
Good point.
> The first time it gets executed, $already_running won't be defined, but
> after that, it will.
You know what I *really* want? ctlinnd runperl 'name_of_perl_sub'. And
you know, that probably wouldn't even be that hard....
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
Re: Use of startup_innd.pl filter
Author: Russ Allbery
Date: Sat, 21 Mar 1998 00:00
Date: Sat, 21 Mar 1998 00:00
16 lines
1198 bytes
1198 bytes
Jeremy <jeremy@exit109.com> writes: > filter_end, apparently. I have some good stuff for this in my "Good > Stuff People Have Sent Me But I Haven't Implemented Yet" file. Okay, there's no mention at all of filter_end in README.perl_hook in the INN 1.7.2-insync-1.1d distribution. So. Am I missing the documentation of this somewhere, does it not currently work...? I do see it in lib/perl.c, but I'm not familiar enough with the INN source to be sure of when that does what. -- Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
Re: Use of startup_innd.pl filter
Author: Russ Allbery
Date: Sat, 21 Mar 1998 00:00
Date: Sat, 21 Mar 1998 00:00
13 lines
1101 bytes
1101 bytes
Jeremy <jeremy@exit109.com> writes: > The only place I've read about it is in my inbox. :) But I'm told it's > there, and that it gets run, if present, at shutdown. Cool. The only additional piece, then, that we need is something to run at startup rather than just at mode changes and filter reloads. -- Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
Re: Use of startup_innd.pl filter
Author: Jeremy
Date: Sat, 21 Mar 1998 00:00
Date: Sat, 21 Mar 1998 00:00
35 lines
2110 bytes
2110 bytes
Russ Allbery <rra@stanford.edu> wrote: > When I first looked at the documentation of this, my thought was > "cool, I can save my cache of message IDs and my hash of rejecting > MD5 signatures when the server shuts down and reload them when the > server restarts, and I don't have to lose all my filter history." > Then, reading the documentation, I couldn't find any way to run > something before the server shuts down (with ctlinnd shutdown). > > Am I missing something, or is there no way to use this to do what I > want? filter_end, apparently. I have some good stuff for this in my "Good Stuff People Have Sent Me But I Haven't Implemented Yet" file. Or, you can just always throttle before shutting down, which I've found to be a good idea anyway, despite the fact that my server no longer wants to cooperate with me on this. > (I also fail to see the point of filter_after_reload. What does > this gain me over code in filter_innd.pl that isn't inside a sub and > therefore runs when the Perl script is loaded? I haven't quite figured this out either, except the slight possibility that you might want to call the filter_after_reload code at some other time too, but there would be better ways to do that too. However, it was a while before I realized that code outside the subs would get executed on each reload... -- Jeremy | jeremy@exit109.com The customer is always right, until he tries to say something.
Re: Use of startup_innd.pl filter
Author: Russ Allbery
Date: Sat, 21 Mar 1998 00:00
Date: Sat, 21 Mar 1998 00:00
17 lines
1178 bytes
1178 bytes
Kenneth Herron <kherron@campus.mci.net> writes: > Call it with > ctlinnd pause 'perlaction dumpstats'; ctlinnd go '' > Extending this with additional commands, or even to execute arbitrary > perl from the command line, is pretty straightforward. Yeah, but I don't *wanna* pause the server. :) And shouldn't have to, just to run a Perl sub. -- Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
Re: Use of startup_innd.pl filter
Author: Kenneth Herron
Date: Sun, 22 Mar 1998 00:00
Date: Sun, 22 Mar 1998 00:00
48 lines
2076 bytes
2076 bytes
In article <m3afajz9xg.fsf@windlord.Stanford.EDU>,
Russ Allbery <rra@stanford.edu> wrote:
|You know what I *really* want? ctlinnd runperl 'name_of_perl_sub'. And
|you know, that probably wouldn't even be that hard....
Surely you guys have noticed the filter_mode hook that's called on
every mode change?
sub filter_mode {
# Don't act on 'ctlinnd go' since any perlaction would
# have to be a repeat of something we just did.
return if ($mode{'NewMode'} eq 'running');
$mode{'reason'} =~ tr/A-Z/a-z/;
my($state);
foreach $_ (split(' ', $mode{'reason'})) {
if (!defined $state) {
if ($_ eq 'perlaction') {
$state = 1;
}
}
elsif ($_ eq 'flushhistory') {
undef %history;
}
elsif ($_ eq 'flushreject') {
undef %reject_mid;
}
elsif ($_ eq 'dumpstats') {
writestats;
}
}
}
Call it with
ctlinnd pause 'perlaction dumpstats'; ctlinnd go ''
Extending this with additional commands, or even to execute arbitrary
perl from the command line, is pretty straightforward.
--
Kenneth Herron -- kherron@campus.mci.net
"When Microsoft first took control of the Funk & Wagnalls Encyclopedia
product, there was a flattering biography of Bill Gates. But it said he
was known as a tough competitor. Now it says that he's known for his
charitable contributions." -- Gary Reback, <http://www.ljx.com/reback/>
Re: Use of startup_innd.pl filter
Author: Jeremy
Date: Sun, 22 Mar 1998 00:00
Date: Sun, 22 Mar 1998 00:00
20 lines
1407 bytes
1407 bytes
Russ Allbery <rra@stanford.edu> wrote: > Okay, there's no mention at all of filter_end in README.perl_hook in the > INN 1.7.2-insync-1.1d distribution. So. Am I missing the documentation > of this somewhere, does it not currently work...? I do see it in > lib/perl.c, but I'm not familiar enough with the INN source to be sure of > when that does what. The only place I've read about it is in my inbox. :) But I'm told it's there, and that it gets run, if present, at shutdown. I've not had a chance to look at it though. -- Jeremy | jeremy@exit109.com Is your ISP providing a *clean* Usenet feed? http://www.exit109.com/~jeremy/news/antispam.html
Re: Use of startup_innd.pl filter
Author: Jeremy
Date: Sun, 22 Mar 1998 00:00
Date: Sun, 22 Mar 1998 00:00
28 lines
1596 bytes
1596 bytes
Russ Allbery <rra@stanford.edu> wrote:
>> The only place I've read about it is in my inbox. :) But I'm told
>> it's there, and that it gets run, if present, at shutdown.
>
> Cool. The only additional piece, then, that we need is something to run
> at startup rather than just at mode changes and filter reloads.
Well, startup_innd.pl is loaded and evaulated at startup. I don't
like it though, because if you want to change anything it becomes a
bit of a pain.
If you want something to run only at startup, you can do something like:
if (not $already_running) {
...stuff...
$already_running = 1;
}
The first time it gets executed, $already_running won't be defined, but
after that, it will.
--
Jeremy | jeremy@exit109.com
"Everything you think you know is wrong." --Jack Chalker
Re: Use of startup_innd.pl filter
Author: Jeremy
Date: Sun, 22 Mar 1998 00:00
Date: Sun, 22 Mar 1998 00:00
30 lines
1890 bytes
1890 bytes
Russ Allbery <rra@stanford.edu> wrote:
>> Well, startup_innd.pl is loaded and evaulated at startup. I don't
>> like it though, because if you want to change anything it becomes a
>> bit of a pain.
>
> I somewhere got the impression that reloading filter.perl reloaded
> it, but maybe I'm wrong.
The last time I played with it was before I realized you could put code
outside the subroutines, so I'm not sure. You *can* define those subs
in filter_innd.pl, and that tends to be a little easier to handle, so
when I've played with them that's what I've done.
The confusing thing is that, even if reloading filter.perl reloads
startup_innd.pl, the filter_before_reload subroutine will be called
*before* your new code is loaded, which is a bit counter-intuitive.
> You know what I *really* want? ctlinnd runperl 'name_of_perl_sub'.
> And you know, that probably wouldn't even be that hard....
Hey... I'll make you famous. :)
--
Jeremy | jeremy@exit109.com
"I wish to have no connection with any ship that does not sail fast;
for I intend to go in harm's way." --John Paul Jones
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads