diff options
| -rw-r--r-- | config.pl.example | 1 | ||||
| -rwxr-xr-x[-rw-r--r--] | gorillanest.pl.cgi | 11 | ||||
| -rwxr-xr-x | gorillanest.pl.fcgi | 9 |
3 files changed, 13 insertions, 8 deletions
diff --git a/config.pl.example b/config.pl.example index fd39608..c6becdf 100644 --- a/config.pl.example +++ b/config.pl.example @@ -1,4 +1,5 @@ # always assume anything to do with files is from project root +use constant LOG_FILE => '/tmp/gorillanest.log'; use constant GIT_ROOT => 'git'; # directory containing all browsable $users/$repositories use constant DB_FILE => 'gorillanest.sqlite3'; # sqlite3 database file location use constant TEMPLATE_ROOT => 'template'; # template directory diff --git a/gorillanest.pl.cgi b/gorillanest.pl.cgi index c964c8f..8f688aa 100644..100755 --- a/gorillanest.pl.cgi +++ b/gorillanest.pl.cgi @@ -2,7 +2,6 @@ use strict; use warnings; - use CGI; use Switch::Back; use Template; @@ -23,7 +22,7 @@ our $template = Template->new({INCLUDE_PATH => 'template'}); # significant dirs only sub GN::directories { my $root = $_[0]; - opendir my $dir, $root or die "Cannot open directory '$root': $!"; + opendir my $dir, $root or die "$root: $!"; my @directories; my %drop = ( '.' => 0, @@ -76,8 +75,8 @@ my %routes = ( '/~([a-zA-Z0-9_.]+)/([a-zA-Z0-9_.]+)' => sub { serve_template("repository.tt", @_) }, ); -my $public = 'git/public'; -my $dbfile = 'gorillanest.sqlite3'; +my $root = GIT_ROOT; +my $dbfile = DB_FILE; my %data = ( found => 0, ); @@ -101,4 +100,6 @@ sub master { serve_template("404.tt"); # XXX missing code } -master() if !caller; 1; +master() if !caller; + +1; diff --git a/gorillanest.pl.fcgi b/gorillanest.pl.fcgi index f4c0687..2692877 100755 --- a/gorillanest.pl.fcgi +++ b/gorillanest.pl.fcgi @@ -6,11 +6,14 @@ use warnings; use Syntax::Keyword::Try; use FCGI; -require "gorillanest.pl.cgi"; - -our $request = FCGI::Request(); +use lib '.'; +# BEGIN { require 'config.pl'; } +BEGIN { require 'gorillanest.pl.cgi'; } try { + open STDERR, '>', LOG_FILE or die LOG_FILE . ": $!"; + my $sock = FCGI::OpenSocket(SOCKET_FILE, 100); + my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV, $sock); while($request->Accept() >= 0) { master(); } |
