ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/myhttpd/shell.pl
(Generate patch)

Comparing Coro/myhttpd/shell.pl (file contents):
Revision 1.19 by root, Fri Sep 28 13:54:21 2001 UTC vs.
Revision 1.23 by root, Sat Dec 8 21:01:17 2007 UTC

1# a server command shell 1# a server command shell
2 2
3use EV;
3use Coro; 4use Coro;
5use Coro::EV;
4use Coro::Handle; 6use Coro::Handle;
5use Coro::Socket; 7use Coro::Socket;
6use Event;
7use Time::HiRes 'time'; 8use Time::HiRes 'time';
8 9
9use Text::Abbrev; 10use Text::Abbrev;
10 11
11my $last_ts = time; 12my $last_ts = time;
12 13
13my %complete; 14my %complete;
14my @commands = qw(quit squit refresh country restart block info print); 15my @commands = qw(quit squit refresh country restart block info print clrdiridx);
15 16
16abbrev \%complete, @commands; 17abbrev \%complete, @commands;
17 18
18sub shell { 19sub shell {
19 my $fh = shift; 20 my $fh = shift;
24 if ($cmd eq "quit") { 25 if ($cmd eq "quit") {
25 print $fh "bye bye.\n";#d# 26 print $fh "bye bye.\n";#d#
26 last; 27 last;
27 } elsif ($cmd eq "squit") { 28 } elsif ($cmd eq "squit") {
28 print $fh "server quit.\n";#d# 29 print $fh "server quit.\n";#d#
29 Event::unloop; 30 EV::unloop;
30 last; 31 last;
31 } elsif ($cmd eq "print") { 32 } elsif ($cmd eq "print") {
32 my @res = eval $_; 33 my @res = eval $_;
33 print $fh "eval: $@\n" if $@; 34 print $fh "eval: $@\n" if $@;
34 print $fh "RES = ", (join " : ", @res), "\n"; 35 print $fh "RES = ", (join " : ", @res), "\n";
35 } elsif ($cmd eq "block") { 36 } elsif ($cmd eq "block") {
36 print "blocked '$_'\n";#d# 37 print "blocked '$_'\n";#d#
37 $conn::blocked{$_} = time + $::BLOCKTIME; 38 $conn::blocked{$_} = [time + $::BLOCKTIME, "blocked by operator"];
38 } elsif ($cmd eq "info") { 39 } elsif ($cmd eq "info") {
39 $::NOW = time+1e-6; 40 $::NOW = time+1e-6;
40 my @data; 41 my @data;
41 for (values %conn::conn) { 42 for (values %conn::conn) {
42 for (values %$_) { 43 for (values %$_) {
54 do "config.pl"; 55 do "config.pl";
55 print $fh "config.pl: $@\n" if $@; 56 print $fh "config.pl: $@\n" if $@;
56 %statdata_cache = (); 57 %statdata_cache = ();
57 conn::read_blockuri; 58 conn::read_blockuri;
58 conn::read_blockref; 59 conn::read_blockref;
60 } elsif ($cmd eq "clrdiridx") {
61 %statdata_cache = ();
62 delete $diridx{$_} for keys %diridx; # server error on %diridx = ();
59 } elsif ($cmd eq "restart") { 63 } elsif ($cmd eq "restart") {
60 $::RESTART = 1; 64 $::RESTART = 1;
61 unloop; 65 EV::unloop;
62 print $fh "restarting, cu!\n"; 66 print $fh "restarting, cu!\n";
63 last; 67 last;
64 } elsif ($cmd eq "country") { 68 } elsif ($cmd eq "country") {
65 print $fh netgeo::ip_request($_), "\n"; 69 print $fh netgeo::ip_request($_), "\n";
66 } 70 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines