Skip to content

Instantly share code, notes, and snippets.

@leedo
Created December 28, 2011 15:56
Show Gist options
  • Save leedo/1528454 to your computer and use it in GitHub Desktop.
Save leedo/1528454 to your computer and use it in GitHub Desktop.
aseed:alice leedo$ perl -Ilib ./bin/multialice.pl
spawning some alice instances
2011-12-28 11:11:53.779200 -0500 info Alice::Standalone: Location: http://127.0.0.1:9000/
2011-12-28 11:11:53.789192 -0500 info Alice::Standalone: Location: http://127.0.0.1:9001/
2011-12-28 11:11:53.813952 -0500 info Alice::Standalone: Location: http://127.0.0.1:9003/
#!/usr/bin/env perl
use Alice::Standalone;
use AnyEvent;
use File::Path qw/make_path/;
my @users = (
{ user => "user1",
port => 9000,
path => "$ENV{HOME}/alice/test/user1/.alice"
},
{ user => "user2",
port => 9001,
path => "$ENV{HOME}/alice/test/user2/.alice"
},
{ user => "user3",
port => 9003,
path => "$ENV{HOME}/alice/test/user3/.alice"
},
);
print "spawning some alice instances\n";
my @alices;
my $cv = AE::cv;
for my $user (@users) {
make_path $user->{path};
my $alice = Alice::Standalone->new(%$user);
my $t; $t = AE::timer 0, 0, sub {
undef $t;
$alice->cv->send;
};
$alice->run;
push @alices, $alice;
}
$_->cv($cv) for @alices;
$cv->recv;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment