2012-09-01 1 views
3

작은 netflow 수집기 (예 : ntop)에서 작업하고 내 프로그램이 시작될 때 웹 서버를 생성하려고합니다. 외부 웹 서버를 구성하지 않아도됩니다. 포크에서 내 앱을 시작하는 방법을 알아 내는데 어려움이 있습니다. 여기에 내가 뭘하는지입니다 : 나는 다음을 받기를 실행하면분기 된 프로세스에 Mojolicious :: Server 포함하기

#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 
. 

내가하려는 일을하는 문서/예제를 찾을 수 없습니다. 나는 올바른 장소를보고 있지 않을 것이라고 확신한다.

답변

4

알아 냈어. 누군가 다른 사람이이 일을 시도한다면, 질문을 타이핑하면 항상 수정의 씨앗을 심는 것처럼 보입니다.

use MyApp; 
use Mojo::Server; 
use Mojo::Server::Daemon; 
use Mojolicious::Commands; 

my $daemon = Mojo::Server::Daemon->new(app => MyApp, listen => ['http://*:5656']); 

$daemon->run(); 

마지막으로 데몬 새 통화에서 응용 프로그램을 넣어 예를 발견 (난 아직도 그 작동 테스트를 중지하고, 내 응용 프로그램에서 오류를 가지고,하지만 난 서버 루프가 시작). 그런 다음 새로운 호출이 루프를 시작하지 않았을 것이라는 것을 깨달았습니다. 그래서 약간 파고 들었습니다. 질문을 삭제 한 것으로 간주되었지만 다른 사람이 유용하다고 생각했습니다.

+1

* 질문을 입력하면 항상 수정 프로그램의 시드를 심는 것처럼 보입니다 ... * 테디 베어 프로그래밍 ++ – DavidO