Commit b84bdfba authored by IKEDA Soji's avatar IKEDA Soji Committed by GitHub
Browse files

Merge pull request #58 from ikedas/reload_fcgi

FCGI scripts will not always restart when they are updated by ikedas
parents 6587df65 ed748e82
......@@ -41,8 +41,6 @@ use Sympa::Log;
use Sympa::SOAP;
use Sympa::SOAP::Transport;
my $birthday = time;
## Load sympa config
unless (Conf::load()) {
printf STDERR
......@@ -83,12 +81,8 @@ my $all_lists = Sympa::List::get_lists('*');
# Soap part
##############################################################################
my $server = Sympa::SOAP::Transport->new();
$server->dispatch_with({'urn:sympasoap' => 'Sympa::SOAP'});
#$server->dispatch_to('--modulesdir--', 'Sympa::SOAP');
$server->handle($birthday);
Sympa::SOAP::Transport->new(cookie_expire => $Conf::Conf{'cookie_expire'})
->dispatch_with({'urn:sympasoap' => 'Sympa::SOAP'})->handle;
__END__
......
......@@ -1008,7 +1008,7 @@ unless (Conf::data_structure_uptodate()) {
our %in;
my $query;
 
my $birthday = time;
my $birthday = [stat $PROGRAM_NAME]->[9];
 
my $bulk = Sympa::Bulk->new;
 
......@@ -1965,14 +1965,15 @@ while ($query = new_loop()) {
send_html('main.tt2');
}
 
# exit if wwsympa.fcgi itself has changed
if ($ENV{'SCRIPT_FILENAME'}
and Sympa::Tools::File::get_mtime($ENV{'SCRIPT_FILENAME'}) >
$birthday) {
$log->syslog('notice',
'Exiting because %s has changed since fastcgi server started',
$ENV{'SCRIPT_FILENAME'});
exit(0);
# Exit if wwsympa.fcgi itself has changed.
if (defined $birthday) {
my $age = [stat $PROGRAM_NAME]->[9];
if (defined $age and $birthday != $age) {
$log->syslog('notice',
'Exiting because %s has changed since FastCGI server started',
$PROGRAM_NAME);
exit(0);
}
}
 
}
......
......@@ -29,15 +29,30 @@ package Sympa::SOAP::Transport;
use strict;
use warnings;
use English qw(-no_match_vars);
use SOAP::Transport::HTTP;
use Sympa::Log;
use Sympa::Session;
use Sympa::Tools::File;
use Sympa::Tools::WWW;
# 'base' pragma doesn't work here
our @ISA = qw(SOAP::Transport::HTTP::FCGI);
my $log = Sympa::Log->instance;
sub new {
my $class = shift;
return $class if ref $class;
my %options = @_;
my $self = $class->SUPER::new();
$self->{_ss_birthday} = [stat $PROGRAM_NAME]->[9] if $PROGRAM_NAME;
$self->{_ss_cookie_expire} = $options{cookie_expire} || 0;
$self;
}
sub request {
my $self = shift;
......@@ -84,11 +99,9 @@ sub response {
if (my $response = $_[0]) {
if (defined $ENV{'SESSION_ID'}) {
my $expire = $main::param->{'user'}{'cookie_delay'}
|| $Conf::Conf{'cookie_expire'};
my $cookie =
Sympa::Session::soap_cookie2($ENV{'SESSION_ID'},
$ENV{'SERVER_NAME'}, $expire);
$ENV{'SERVER_NAME'}, $self->{_ss_cookie_expire});
$response->headers->push_header('Set-Cookie2' => $cookie);
}
}
......@@ -97,25 +110,29 @@ sub response {
}
## Redefine FCGI's handle subroutine
sub handle ($$) {
my $self = shift->new;
my $birthday = shift;
sub handle {
my $self = shift->new;
my ($r1, $r2);
my $fcgirq = $self->{_fcgirq};
## If fastcgi changed on disk, die
## Apache will restart the process
while (($r1 = $fcgirq->Accept()) >= 0) {
$r2 = $self->SOAP::Transport::HTTP::CGI::handle;
if (Sympa::Tools::File::get_mtime($ENV{'SCRIPT_FILENAME'}) >
$birthday) {
exit(0);
# Exit if script itself has changed.
my $birthday = $self->{_ss_birthday};
if (defined $birthday and $PROGRAM_NAME) {
my $age = [stat $PROGRAM_NAME]->[9];
if (defined $age and $birthday != $age) {
$log->syslog(
'notice',
'Exiting because %s has changed since FastCGI server started',
$PROGRAM_NAME
);
exit(0);
}
}
# print
# "Set-Cookie: sympa_altemails=olivier.salaun%40cru.fr; path=/; expires=Tue , 19-Oct-2004 14 :08:19 GMT\n";
}
return undef;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment