在一个小的 netflow 收集器(如 ntop)上工作,我想在我的程序启动时生成一个 Web 服务器(不想强迫人们配置一个外部 Web 服务器)。我在弄清楚如何让我的应用程序在 fork 中启动时遇到了一些麻烦。这就是我正在做的事情:
#This is basically what the child process is doing.
#running this outside of my fork does the same thing.
use myApp;
use Mojo::Server;
use Mojo::Server::Daemon;
use Mojolicious::Commands;
my $daemon = Mojo::Server::Daemon->new( listen => ['http://*:5656'] );
Mojolicious::Commands->start_app('myApp');
myApp.pm 包含
sub startup
{
my $self = shift();
my $r = $self->routes;
$r->get('/') => sub {
my $self = shift;
$self->render( text => "Howdy!!" );
};
}
当我运行它时,我得到以下信息。. .
usage: ./FlowTrack.pl COMMAND [OPTIONS]
Tip: CGI and PSGI environments can be automatically detected very often and
work without commands.
These commands are currently available:
cgi Start application with CGI.
cpanify Upload distribution to CPAN.
daemon Start application with HTTP and WebSocket server.
eval Run code against application.
generate Generate files and directories from templates.
get Perform HTTP request.
.
.
etc
.
我还没有找到做我想做的事情的文档/示例。我确定我只是没有找对地方。