Created
June 29, 2018 15:39
-
-
Save s1037989/f9f77c495097546adcdeb2da7eb7c939 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use lib 'lib'; | |
use lib 'Mojocron/lib'; | |
use Mojo::Log; | |
use Mojo::HelloWorld; | |
use Mojo::IOLoop; | |
use Mojo::Server::Daemon; | |
use Mojo::Server::Morbo; | |
use Mojo::Server::Prefork; | |
use Mojo::File 'tempfile'; | |
use Mojo::Loader 'data_section'; | |
use Mojocron; | |
my $log = Mojo::Log->new; | |
my $daemon = Mojo::IOLoop->subprocess->run( | |
sub { | |
my $subprocess = shift; | |
my $daemon = Mojo::Server::Daemon->new(app => Mojo::HelloWorld->new); | |
$daemon->listen(['http://*:8083']); | |
$daemon->run; | |
return 1; | |
}, | |
sub { | |
my ($subprocess, $err, @results) = @_; | |
warn $err; | |
} | |
); | |
$log->debug($daemon->pid); | |
my $prefork = Mojo::IOLoop->subprocess->run( | |
sub { | |
my $subprocess = shift; | |
my $prefork = Mojo::Server::Prefork->new(app => Mojo::HelloWorld->new); | |
$prefork->listen(['http://*:8081']); | |
$prefork->run; | |
return 1; | |
}, | |
sub { | |
my ($subprocess, $err, @results) = @_; | |
warn $err; | |
} | |
); | |
$log->debug($prefork->pid); | |
my $morbo = Mojo::IOLoop->subprocess->run( | |
sub { | |
my $subprocess = shift; | |
my $app = tempfile->spurt(data_section('main', 'morbo')); | |
$log->debug(sprintf "Morbo file: %s", $app->to_abs); | |
#warn $app->slurp; | |
my $morbo = Mojo::Server::Morbo->new; | |
$morbo->daemon->listen(['http://*:8082']); | |
#$morbo->backend->watch($app->to_abs); | |
$morbo->run($app->to_abs); | |
return 1; | |
}, | |
sub { | |
my ($subprocess, $err, @results) = @_; | |
warn $err; | |
} | |
); | |
$log->debug($morbo->pid); | |
my $mojocron = Mojo::IOLoop->subprocess->run( | |
sub { | |
my $subprocess = shift; | |
my $mojocron = Mojocron->new(app => Mojo::HelloWorld->new, namespaces => ['MyApp::Mojocron'])->start; | |
$log->debug(sprintf "Mojocron pid: %s", $mojocron->subprocess->pid); | |
Mojo::IOLoop->start unless Mojo::IOLoop->is_running; | |
return 1; | |
}, | |
sub { | |
my ($subprocess, $err, @results) = @_; | |
warn $err; | |
} | |
); | |
$log->debug($mojocron->pid); | |
Mojo::IOLoop->start unless Mojo::IOLoop->is_running; | |
__DATA__ | |
@@ morbo | |
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
app->log->debug(sprintf "Starting Morbo %s", app->moniker); | |
get '/' => sub { | |
my $c = shift; | |
$c->render(template => 'index'); | |
}; | |
app->start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment