1 | #!/OPT/BIn/perl |
1 | #!/opt/bIn/perl |
2 | |
2 | |
3 | =head1 NAME |
3 | =head1 NAME |
4 | |
4 | |
5 | aemp - AnyEvent:MP utility |
5 | aemp - AnyEvent:MP utility |
6 | |
6 | |
… | |
… | |
80 | All configuration data is stored in a human-readable (JSON) config file |
80 | All configuration data is stored in a human-readable (JSON) config file |
81 | stored in F<~/.perl-anyevent-mp> (or F<%appdata%/perl-anyevent-mp> |
81 | stored in F<~/.perl-anyevent-mp> (or F<%appdata%/perl-anyevent-mp> |
82 | on loser systems). Feel free to look at it or edit it, the format is |
82 | on loser systems). Feel free to look at it or edit it, the format is |
83 | relatively simple. |
83 | relatively simple. |
84 | |
84 | |
|
|
85 | =head2 SPECIFYING ARGUMENTS |
|
|
86 | |
|
|
87 | Arguments can be specified just as with any other shell command, with a |
|
|
88 | few special cases: |
|
|
89 | |
|
|
90 | If the I<first> argument starts with a literal C<[>-character, then it is |
|
|
91 | interpreted as a UTF-8 encoded JSON text. The resulting array replaces all |
|
|
92 | arguments. |
|
|
93 | |
|
|
94 | Otherwise, if I<any> argument starts with one of C<[>, C<{> or C<">, then |
|
|
95 | it is interpreted as UTF-8 encoded JSON text (or a single value in case of |
|
|
96 | C<">), and the resulting reference or scalar replaces the argument. |
|
|
97 | |
|
|
98 | This allows you, for example, to specify binds in F<aemp run> (using POSIX |
|
|
99 | shell syntax): |
|
|
100 | |
|
|
101 | aemp run binds '["*:4040"]' |
|
|
102 | |
85 | =head2 RUNNING A NODE |
103 | =head2 RUNNING A NODE |
86 | |
104 | |
87 | This can be used to run a node - together with some services, this makes |
105 | This can be used to run a node - together with some services, this makes |
88 | it unnecessary to write any wrapper programs. |
106 | it unnecessary to write any wrapper programs. |
89 | |
107 | |
… | |
… | |
401 | use common::sense; |
419 | use common::sense; |
402 | |
420 | |
403 | # should come before anything else, so all modules |
421 | # should come before anything else, so all modules |
404 | # will be loaded on each restart |
422 | # will be loaded on each restart |
405 | BEGIN { |
423 | BEGIN { |
|
|
424 | if (@ARGV == 1 && $ARGV[0] =~ /^\[/) { |
|
|
425 | require JSON::XS; |
|
|
426 | @ARGV = @{ JSON::XS->new->utf8->decode (shift) }; |
|
|
427 | } else { |
|
|
428 | for (@ARGV) { |
|
|
429 | if (/^[\[\{\"]/) { |
|
|
430 | require JSON::XS; |
|
|
431 | $_ = JSON::XS->new->utf8->allow_nonref->decode ($_); |
|
|
432 | } |
|
|
433 | } |
|
|
434 | } |
|
|
435 | |
406 | if ($ARGV[0] eq "run") { |
436 | if ($ARGV[0] eq "run") { |
407 | shift; |
437 | shift; |
408 | |
438 | |
409 | # d'oh |
439 | # d'oh |
410 | require AnyEvent::Watchdog; |
440 | require AnyEvent::Watchdog; |