1 | # a server command shell |
1 | # a server command shell |
2 | |
2 | |
|
|
3 | use EV; |
3 | use Coro; |
4 | use Coro; |
|
|
5 | use Coro::EV; |
4 | use Coro::Handle; |
6 | use Coro::Handle; |
5 | use Coro::Socket; |
7 | use Coro::Socket; |
6 | use Event; |
|
|
7 | use Time::HiRes 'time'; |
8 | use Time::HiRes 'time'; |
8 | |
9 | |
9 | use Text::Abbrev; |
10 | use Text::Abbrev; |
10 | |
11 | |
11 | my $last_ts = time; |
12 | my $last_ts = time; |
… | |
… | |
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"; |
… | |
… | |
59 | } elsif ($cmd eq "clrdiridx") { |
60 | } elsif ($cmd eq "clrdiridx") { |
60 | %statdata_cache = (); |
61 | %statdata_cache = (); |
61 | delete $diridx{$_} for keys %diridx; # server error on %diridx = (); |
62 | delete $diridx{$_} for keys %diridx; # server error on %diridx = (); |
62 | } elsif ($cmd eq "restart") { |
63 | } elsif ($cmd eq "restart") { |
63 | $::RESTART = 1; |
64 | $::RESTART = 1; |
64 | unloop; |
65 | EV::unloop; |
65 | print $fh "restarting, cu!\n"; |
66 | print $fh "restarting, cu!\n"; |
66 | last; |
67 | last; |
67 | } elsif ($cmd eq "country") { |
68 | } elsif ($cmd eq "country") { |
68 | print $fh netgeo::ip_request($_), "\n"; |
69 | print $fh netgeo::ip_request($_), "\n"; |
69 | } |
70 | } |