From d5c3ef85f9324b81a179284fedf02e1658a7620a Mon Sep 17 00:00:00 2001 From: Emil Williams Date: Thu, 21 Aug 2025 00:12:20 +0000 Subject: [PATCH] Optional Socketing & Redundant config.pl --- config.default.pl | 15 +++++++++++++++ config.pl.default | 7 ------- gorillanest.pl.cgi | 1 + gorillanest.pl.fcgi | 3 +-- 4 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 config.default.pl delete mode 100644 config.pl.default diff --git a/config.default.pl b/config.default.pl new file mode 100644 index 0000000..b95d005 --- /dev/null +++ b/config.default.pl @@ -0,0 +1,15 @@ +# always assume anything to do with files is from project root + +use constant LOG_FILE => '/tmp/gorillanest.log'; +use constant SOCKET_FILE => '/tmp/gorillanest.socket'; +use constant DB_FILE => 'gorillanest.sqlite3'; # sqlite3 + +use constant TEMPLATE_ROOT => 'template'; # template directory +use constant GIT_ROOT => 'git'; # git directory (~user/repo) + +# If you're using lighttpd, set this to 1 +# This disables SOCKET_FILE and lets the socket handling be externally managed +use constant BARE_REQUEST => 0; + +use constant SOCKET_MAX_CONNECTIONS => 100; +1; diff --git a/config.pl.default b/config.pl.default deleted file mode 100644 index c6becdf..0000000 --- a/config.pl.default +++ /dev/null @@ -1,7 +0,0 @@ -# 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 -use constant USER_REPOSITORY => qr{^/([a-zA-Z0-9_.]+)(?:/([a-zA-Z0-9_.]+))?}; # $1 = username, $2 = repository fullname -1; diff --git a/gorillanest.pl.cgi b/gorillanest.pl.cgi index 6d01d7c..cebe11b 100755 --- a/gorillanest.pl.cgi +++ b/gorillanest.pl.cgi @@ -21,6 +21,7 @@ use Data::Dumper; use Git::Repository; use lib '.'; +BEGIN { require 'config.default.pl'; } BEGIN { require 'config.pl'; } sub info { diff --git a/gorillanest.pl.fcgi b/gorillanest.pl.fcgi index a9d77c0..7dc343f 100755 --- a/gorillanest.pl.fcgi +++ b/gorillanest.pl.fcgi @@ -11,8 +11,7 @@ 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); + my $request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%ENV, BARE_REQUEST ? 0 : FCGI::OpenSocket(SOCKET_FILE, SOCKET_MAX_CONNECTIONS)); while($request->Accept() >= 0) { master(); } -- 2.39.5