Skip to content

Commit

Permalink
Merging fcgi support into main branches
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.code.sf.net/p/ledger-smb/code/branches/1.3@5305 4979c152-3d1c-0410-bac9-87ea11338e46
  • Loading branch information
einhverfr committed Dec 6, 2012
1 parent 37c1155 commit 95c272d
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Supported Presently

Changelog for 1.3.26
* Added db statistics post-upgrade and pre/post rebuild (Chris T, 3586113)
* Merged in fcgi support from addons (Chris T)

Changelog for 1.3.25
* Fixed internal server errors on LedgerSMB->error() during new() (Chris T)
Expand Down
45 changes: 45 additions & 0 deletions tools/app.psgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/plackup -s FCGI ledgersmb.fcgi

package LedgerSMB::FCGI;

use CGI::Emulate::PSGI;
use FCGI::ProcManager;
use FindBin;
# Preloads
use LedgerSMB;
use LedgerSMB::Form;
use LedgerSMB::Sysconfig;
use LedgerSMB::Template;
use LedgerSMB::Template::LaTeX;
use LedgerSMB::Template::HTML;
use LedgerSMB::Locale;
use LedgerSMB::DBObject;
use LedgerSMB::File;

BEGIN {
lib->import($FindBin::Bin) unless $ENV{mod_perl}
}

# Process Manager
my $proc_manager = FCGI::ProcManager->new({ n_processes => 10 });


my $app = CGI::Emulate::PSGI->handler(
sub {
if (my $cpid = fork()){
wait
} else {
$proc_manager->pm_pre_dispatch();
$uri = $ENV{REQUEST_URI};
$uri =~ s/\?.*//;
$ENV{SCRIPT_NAME} = $uri;
$ENV{SCRIPT_NAME} =~ m/([^\/\\]*.pl)\?*.*$/;

my $script = $1;
warn $script;
do "./$script";
$proc_manager->pm_post_dispatch();
}
}
);

63 changes: 63 additions & 0 deletions tools/lsmb_13-fcgi.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This file must be edited to substitute the current path with WORKING_DIR

Alias /ledgersmb_1.3 WORKING_DIR/
LoadModule fastcgi_module modules/mod_fastcgi.so

LogLevel debug

FastCgiExternalServer WORKING_DIR/ledgersmb.fcgi -socket /var/run/httpd/fastcgi/lsmb.sock -idle-timeout 240 -pass-header Authorization

<Directory WORKING_DIR>

# Rewrite rule to allow HTTP Authorization information to the scripts only
# from this directory.
RewriteEngine On
RewriteBase /ledgersmb_1.3/
RewriteRule ^([^/]*\.pl) ledgersmb.fcgi/$0


AllowOverride All
Options Includes FollowSymlinks +ExecCGI


# By default, only allow from localhost. If you change this, please be
# advised that you should use SSL protection on any and all network
# connections that access this application in order to protect usernames and
# passwords.

# The rest of this file just tightens up security.
<Files ~ "\.conf$">
Order Deny,Allow
Deny from All
</Files>
</Directory>

<Directory WORKING_DIR/users>
Order Deny,Allow
Deny from All
</Directory>

<Directory WORKING_DIR/bin>
Order Deny,Allow
Deny from All
</Directory>

<Directory WORKING_DIR/utils>
Order Deny,Allow
Deny from All
</Directory>

<Directory WORKING_DIR/spool>
Order Deny,Allow
Deny from All
</Directory>

<Directory WORKING_DIR/templates>
Order Deny,Allow
Deny from All
</Directory>

<Directory WORKING_DIR/LedgerSMB>
Order Deny,Allow
Deny from All
</Directory>
18 changes: 18 additions & 0 deletions tools/system/ledgersmb.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=LedgerSMB FCGI service
After=syslog.target

[Service]
Type=forkking
PIDfile=/var/run/httpd/lsmb.pid
RemainAfterExit=yes
ExecStart=/usr/bin/lsmbstart
ExecStop=/usr/bin/lsmbstop
Environment=BOOTUP=serial
Environment=CONSOLETYPE=serial
StandardOutput=syslog
StandardError=syslog

[Install]
WantedBy=basic.target

5 changes: 5 additions & 0 deletions tools/system/lsmbstart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/bash

cd /usr/share/ledgersmb
plackup -s FCGI -D --listen /var/run/httpd/fastcgi/lsmb.sock

4 changes: 4 additions & 0 deletions tools/system/lsmbstop
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/bash

killall perl-fcgi-pm

0 comments on commit 95c272d

Please sign in to comment.