Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 77ee93fc

Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt

  • ID 77ee93fc2852fa057f03229cecde6b389f65d6dd
  • Vorgänger cdacfe1c
  • Nachfolger 7d42e176

Optionaler, automatischer FCGI-Restart nach Request bei Programmänderungen

Muss in Konfiguration in [debug] mit restart_fcgi_process_on_changes
angeschaltet werden. Überwacht alle Dateien in SL, bin, config,
templates/webpages sowie einige im Basisverzeichnis auf Änderungen des
Modifizierungszeitstempels.

Unterschiede anzeigen:

SL/Dispatcher.pm
12 12
use DateTime;
13 13
use Encode;
14 14
use English qw(-no_match_vars);
15
use File::Basename;
16
use List::MoreUtils qw(all);
17
use List::Util qw(first);
18
use POSIX;
15 19
use SL::Auth;
16 20
use SL::LXDebug;
17 21
use SL::LxOfficeConf;
......
20 24
use SL::Form;
21 25
use SL::Helper::DateTime;
22 26
use SL::Template::Plugin::HTMLFixes;
23
use List::Util qw(first);
24
use File::Basename;
25 27

  
26 28
# Trailing new line is added so that Perl will not add the line
27 29
# number 'die' was called in.
28 30
use constant END_OF_REQUEST => "END-OF-REQUEST\n";
29 31

  
32
my %fcgi_file_cache;
33

  
30 34
sub new {
31 35
  my ($class, $interface) = @_;
32 36

  
......
73 77
}
74 78

  
75 79
sub pre_startup_setup {
80
  my ($self) = @_;
81

  
76 82
  SL::LxOfficeConf->read;
77 83
  _init_environment();
78 84

  
......
94 100

  
95 101
  $SIG{__WARN__} = sub {
96 102
    $::lxdebug->warn(@_);
97
  }
103
  };
104

  
105
  $self->_cache_file_modification_times;
98 106
}
99 107

  
100 108
sub pre_startup_checks {
......
102 110
}
103 111

  
104 112
sub pre_startup {
105
  pre_startup_setup();
106
  pre_startup_checks();
113
  my ($self) = @_;
114
  $self->pre_startup_setup;
115
  $self->pre_startup_checks;
107 116
}
108 117

  
109 118
sub require_main_code {
......
244 253
  Form::disconnect_standard_dbh;
245 254

  
246 255
  $::lxdebug->end_request;
256

  
257
  $self->_watch_for_changed_files;
258

  
247 259
  $::lxdebug->leave_sub;
248 260
}
249 261

  
......
319 331
  return ($controller, $action);
320 332
}
321 333

  
334
sub _cache_file_modification_times {
335
  my ($self) = @_;
336

  
337
  return unless $self->_interface_is_fcgi && $::lx_office_conf{debug}->{restart_fcgi_process_on_changes};
338

  
339
  require File::Find;
340
  require POSIX;
341

  
342
  my $wanted = sub {
343
    return unless $File::Find::name =~ m/\.(?:pm|f?pl|html|conf|conf\.default)$/;
344
    $fcgi_file_cache{ $File::Find::name } = (stat $File::Find::name)[9];
345
  };
346

  
347
  my $cwd = POSIX::getcwd();
348
  File::Find::find($wanted, map { "${cwd}/${_}" } qw(config bin SL templates/webpages));
349
  map { my $name = "${cwd}/${_}"; $fcgi_file_cache{$name} = (stat $name)[9] } qw(admin.pl dispatcher.fpl);
350
}
351

  
352
sub _watch_for_changed_files {
353
  my ($self) = @_;
354

  
355
  return unless $self->_interface_is_fcgi && $::lx_office_conf{debug}->{restart_fcgi_process_on_changes};
356

  
357
  my $ok = all { (stat($_))[9] == $fcgi_file_cache{$_} } keys %fcgi_file_cache;
358
  return if $ok;
359
  $::lxdebug->message(LXDebug::DEBUG1(), "Program modifications detected. Restarting.");
360
  exit;
361
}
362

  
322 363
sub get_standard_filehandles {
323 364
  my $self = shift;
324 365

  

Auch abrufbar als: Unified diff