aboutsummaryrefslogtreecommitdiff
path: root/perl/fcgi.pl
blob: 823cd865231fb74042021d7f645fc2d09194f173 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env perl

use strict;
use warnings;

use Syntax::Keyword::Try;
use FCGI;

use lib qw(perl);
BEGIN { require 'cgi.pl'; }

while (1) {
    try {
        my $request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%ENV, BARE_REQUEST ? 0 : FCGI::OpenSocket(SOCKET_FILE, SOCKET_MAX_CONNECTIONS));
        my ($data, $routes, $routes_cache) = GN::init();
        while($request->Accept() >= 0) {
            GN::cgi($data, $routes, $routes_cache);
        }
    } catch ($error) {
        info("Crashed: $error");
    }
    exit 1 unless (IMMORTAL);
}