1 | #!/opt/bin/perl |
1 | #!/opt/bin/perl |
|
|
2 | |
|
|
3 | |
|
|
4 | # very stupid leak checker, checks after some time whether the passed |
|
|
5 | # object is still around and tracks it via Devel::FindRef. |
|
|
6 | sub leakcheck($$) {#d# |
|
|
7 | my ($after, $ref) = @_; |
|
|
8 | |
|
|
9 | use EV;#d# |
|
|
10 | Scalar::Util::weaken $ref; |
|
|
11 | |
|
|
12 | my $w; $w = EV::timer $after, 0, sub { |
|
|
13 | undef $w; |
|
|
14 | return unless $ref; |
|
|
15 | |
|
|
16 | require Devel::FindRef; |
|
|
17 | warn "object $ref still alive after $after seconds:\n" |
|
|
18 | . Devel::FindRef::track ($ref, 30); |
|
|
19 | }; |
|
|
20 | } |
2 | |
21 | |
3 | =head1 NAME |
22 | =head1 NAME |
4 | |
23 | |
5 | aemp - AnyEvent:MP utility |
24 | aemp - AnyEvent:MP utility |
6 | |
25 | |
… | |
… | |
70 | |
89 | |
71 | use common::sense; |
90 | use common::sense; |
72 | |
91 | |
73 | # should come before anything else, so all modules |
92 | # should come before anything else, so all modules |
74 | # will be loaded on each restart |
93 | # will be loaded on each restart |
75 | BEGIN { |
94 | #BEGIN { |
76 | if ($ARGV[0] eq "run") { |
95 | if ($ARGV[0] eq "run") { |
77 | shift; |
96 | shift; |
78 | |
97 | |
79 | # d'oh |
98 | # d'oh |
80 | require AnyEvent::Watchdog; |
99 | # require AnyEvent::Watchdog; |
81 | # now we can load extra modules |
100 | # now we can load extra modules |
82 | |
101 | |
83 | AnyEvent::Watchdog::autorestart (1); |
102 | # AnyEvent::Watchdog::autorestart (1); |
84 | AnyEvent::Watchdog::heartbeat (300); |
103 | # AnyEvent::Watchdog::heartbeat (300); |
85 | |
104 | |
86 | require AnyEvent; |
105 | require AnyEvent; |
87 | require AnyEvent::MP; |
106 | require AnyEvent::MP; |
88 | AnyEvent::MP::initialise_node (@ARGV); |
107 | AnyEvent::MP::initialise_node (@ARGV); |
89 | |
108 | |
90 | AnyEvent::detect () eq "AnyEvent::Impl::EV" |
109 | AnyEvent::detect () eq "AnyEvent::Impl::EV" |
91 | ? EV::loop () |
110 | ? EV::loop () |
92 | : AE::cv ()->recv; |
111 | : AE::cv ()->recv; |
93 | } |
112 | } |
94 | } |
113 | #} |
95 | |
114 | |
96 | use Carp (); |
115 | use Carp (); |
97 | |
116 | |
98 | use JSON::XS; |
117 | use JSON::XS; |
99 | |
118 | |