X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fbin%2Fstandalone_httpd;h=7b447050bd5fb20267eedb8345476e7ccf3af456;hb=6662dd7c5260d74d92df0437d1eeebcb2baa6fe4;hp=1057ce0ea71eb5dd832563e6684cdf8f3dbdcfe3;hpb=40a7b3dc653e099f7bd0bd762b649b04c4432db2;p=freeside.git diff --git a/rt/bin/standalone_httpd b/rt/bin/standalone_httpd index 1057ce0ea..7b447050b 100755 --- a/rt/bin/standalone_httpd +++ b/rt/bin/standalone_httpd @@ -2,8 +2,8 @@ # BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: -# -# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +# +# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -49,19 +49,138 @@ use warnings; use strict; +# fix lib paths, some may be relative BEGIN { - use lib( "/opt/rt3/local/lib", "/opt/rt3/lib"); - use RT; - RT::LoadConfig(); - if ($RT::DevelMode) { require Module::Refresh; } + require File::Spec; + my @libs = ("lib", "local/lib"); + my $bin_path; + + for my $lib (@libs) { + unless ( File::Spec->file_name_is_absolute($lib) ) { + unless ($bin_path) { + if ( File::Spec->file_name_is_absolute(__FILE__) ) { + $bin_path = ( File::Spec->splitpath(__FILE__) )[1]; + } + else { + require FindBin; + no warnings "once"; + $bin_path = $FindBin::Bin; + } + } + $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib ); + } + unshift @INC, $lib; + } + } -RT::Init(); +use RT; +RT::LoadConfig(); +RT->InitLogging(); +if (RT->Config->Get('DevelMode')) { require Module::Refresh; } + +RT::CheckPerlRequirements(); +RT->InitPluginPaths(); + +my $explicit_port = shift @ARGV; +my $port = $explicit_port || RT->Config->Get('WebPort') || '8080'; + + +require RT::Handle; +my ($integrity, $state, $msg) = RT::Handle->CheckIntegrity; + +unless ( $integrity ) { + print STDERR <ConfigFile && !-w _) { + die 'Since your configuration exists (' + . RT::Installer->ConfigFile + . ") but is not writable, I'm refusing to do anything.\n"; + } -my $port = shift @ARGV || $RT::WebPort || '8080'; -use RT::Interface::Web::Standalone; + RT->Config->Set( 'LexiconLanguages' => '*' ); + RT::I18N->Init; + + RT->InstallMode(1); +} else { + RT->ConnectToDatabase(); + RT->InitSystemObjects(); + RT->InitClasses( Heavy => 1 ); + RT->InitPlugins(); + RT->Config->PostLoadCheck(); + + my ($status, $msg) = RT::Handle->CheckCompatibility( + $RT::Handle->dbh, 'post' + ); + unless ( $status ) { + print STDERR $msg, "\n\n"; + exit -1; + } +} + +require RT::Interface::Web::Standalone; my $server = RT::Interface::Web::Standalone->new; -$server->port($port); -$server->run(); +run_server($port); +exit 0; +sub run_server { + my $port = shift; + $server->port($port); + eval { $server->run() }; + if ( my $err = $@ ) { + handle_startup_error($err); + } +} + +sub handle_startup_error { + my $err = shift; + if ( $err =~ /bind: Permission denied/ ) { + handle_bind_error(); + } else { + die + "Something went wrong while trying to run RT's standalone web server:\n\t" + . $err; + } +} + + +sub handle_bind_error { + + print STDERR <