Perl FCGI를 사용하는 경우 exit를 사용하지 않고 스크립트를 종료하는 방법. 요일을 검색 한 후 내가 발견 한 유일한 해결책은 주 스크립트에서 레이블로 건너 뛰는 것입니다. 아래는 주요 index.fcgi 코드입니다.Perl FCGI 종료하지 않고 종료
$fcgi_requests = 0; # the number of requests this fcgi process handled.
$handling_request = 0;
$exit_requested = 0;
$app_quit_request = 0; # End the application but not the FCGI process
# workaround for known bug in libfcgi
while (($ignore) = each %ENV) { }
$fcgi_request = FCGI::Request();
#$fcgi_request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV, $socket);
sub sig_handler {
my ($callpackage, $callfile, $callline) = caller;
if ($app_quit_request) {
$app_quit_request = 0;
goto ABORTLABEL;
}
$exit_requested = 1;
exit(0) if !$handling_request;
}
$SIG{USR1} = \&sig_handler;
$SIG{TERM} = \&sig_handler;
$SIG{PIPE} = 'IGNORE';
#The goal of fast cgi is to load the program once, and iterate in a loop for every request.
while ($handling_request = ($fcgi_request->Accept() >= 0)) {
process_fcgi_request();
$handling_request = 0;
last if $exit_requested;
#exit if -M $ENV{SCRIPT_FILENAME} < 0; # Autorestart
}
$fcgi_request->Finish();
exit(0);
#=========================================================#
sub process_fcgi_request() {
$fcgi_requests++;
# dispatch current request
my_app();
$fcgi_request->Finish();
}
#=========================================================#
# let it think we are done, used by abort
ABORTLABEL:
$fcgi_request->Finish();
#=========================================================#
주요 요구 I는 계정 모듈에 로그인 기능 내부 예컨대 긴 깊이에 의해 호출 될 수있다 insidi 서브 모듈 내부에서 프로그램 실행을 중지 할 것이다. 물론 fcgi 프로세스가 종료 될 것이기 때문에 exit를 사용할 수 없습니다. 모든 오류를 시도하고 모듈을 모두 시도해보고 프로세스를 종료하는 die를 사용하십시오. 물론 각 하위의 리턴을 사용할 수는 있지만 fcgi에 대한 전체 프로그램을 다시 작성해야합니다.
감사 마태 복음 상세한 정보. 이 문제는 전체 OO 방식으로 다시 작성하기가 어려운 오래된 거대한 응용 프로그램의 문제이므로 하위 모듈 내부의 특정 지점에서 실행을 종료하면됩니다. 위의 논리는 현재 작동하지만 그 논리가 정확하고 수용 가능한 것입니까? – daliaessam