1 | #! perl |
1 | #! perl |
2 | |
2 | |
|
|
3 | use Coro::Debug; |
3 | use IO::Socket; |
4 | use IO::Socket; |
4 | use Storable qw/nfreeze thaw/; |
5 | use Storable qw/nfreeze thaw/; |
5 | |
6 | |
6 | my %global; # for use by eval'ed commands |
7 | my %global; # for use by eval'ed commands |
7 | |
8 | |
… | |
… | |
22 | You can freely use \$a .. \$z and \@l and \%l |
23 | You can freely use \$a .. \$z and \@l and \%l |
23 | |
24 | |
24 | Useful commands (note the '&'): |
25 | Useful commands (note the '&'): |
25 | |
26 | |
26 | reload_perl & |
27 | reload_perl & |
|
|
28 | reload_config & |
27 | reload_regions & |
29 | reload_regions & |
28 | reload_facedata & |
30 | reload_facedata & |
29 | reload_treasures & |
31 | reload_treasures & |
30 | reload_archetypes & |
32 | reload_archetypes & |
|
|
33 | ext::help::reload & |
|
|
34 | ext::books::reload & |
|
|
35 | ext::map_tags::reload & |
|
|
36 | ext::map_world::reload & |
31 | EOF |
37 | EOF |
32 | print "\n> "; |
38 | print "\n> "; |
33 | |
39 | |
34 | Event->io (fd => $fh, poll => 'r', data => 0, cb => sub { |
40 | Event->io (fd => $fh, poll => 'r', data => 0, cb => sub { |
35 | if (defined (my $cmd = <$fh>)) { |
41 | if (defined (my $cmd = <$fh>)) { |
36 | $cmd =~ s/\s+$//; |
42 | $cmd =~ s/\s+$//; |
37 | |
43 | |
38 | if ($cmd =~ /^\s*exit\b/i) { |
44 | if ($cmd =~ /^\s*exit\b/i) { |
39 | print "will not exit() server.\n"; |
45 | print "will not exit() server.\n"; |
|
|
46 | } elsif ($cmd =~ s/^coro\s+// or $cmd =~ /^(?:ps|bt\s)/) { |
|
|
47 | Coro::Debug::command $cmd; |
40 | } else { |
48 | } else { |
41 | my $sub = sub { |
49 | my $sub = sub { |
42 | package cf; |
50 | package cf; |
43 | select $fh; |
51 | select $fh; |
44 | |
52 | |
… | |
… | |
57 | print "result:\n", cf::dumpval @res > 1 ? \@res : $res[0] if @res; |
65 | print "result:\n", cf::dumpval @res > 1 ? \@res : $res[0] if @res; |
58 | print "\n> "; |
66 | print "\n> "; |
59 | }; |
67 | }; |
60 | |
68 | |
61 | if ($cmd =~ s/\s*&$//) { |
69 | if ($cmd =~ s/\s*&$//) { |
62 | Coro::async_pool { $sub->() }; |
70 | Coro::async { $sub->() }; |
63 | } else { |
71 | } else { |
64 | $sub->(); |
72 | $sub->(); |
65 | } |
73 | } |
66 | } |
74 | } |
67 | |
75 | |
… | |
… | |
76 | if ($cf::CFG{perl_shell}) { |
84 | if ($cf::CFG{perl_shell}) { |
77 | if (my $listen = new IO::Socket::INET LocalAddr => $cf::CFG{perl_shell}, Listen => 1, ReuseAddr => 1) { |
85 | if (my $listen = new IO::Socket::INET LocalAddr => $cf::CFG{perl_shell}, Listen => 1, ReuseAddr => 1) { |
78 | Event->io (fd => $listen, poll => 'r', data => cf::WF_AUTOCANCEL, cb => sub { tcp_serve $listen->accept }); |
86 | Event->io (fd => $listen, poll => 'r', data => cf::WF_AUTOCANCEL, cb => sub { tcp_serve $listen->accept }); |
79 | } |
87 | } |
80 | } |
88 | } |
|
|
89 | |
|
|
90 | |