Skip to content

Instantly share code, notes, and snippets.

@petr999
Created January 16, 2010 12:06

Revisions

  1. petr999 revised this gist Jan 19, 2010. 1 changed file with 22 additions and 0 deletions.
    22 changes: 22 additions & 0 deletions gistfile4.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    # Nginx config, the server{} section internals
    charset utf-8;
    root /var/www/bugzilla;
    location ~ /\.ht.*|.*(localconfig.*|\.p[ml])$ {
    deny all;
    }
    location /Bugzilla { deny all; }
    location ~ ^/data/webdot/[^/].*\.dot$ { deny all; }
    location ~ ^/data/attachments/[^/]* { deny all; }
    location = /data/duplicates.rdf { allow all; }
    location ~ ^/data/[^/]* { deny all; }
    location ~ \.cgi$ {
    fastcgi_pass unix:/tmp/spawner.sock;
    }
    if ($uri ~ "^(.*\.(pl|cgi))(/.+)?$") {
    set $unpath_script_name $1;
    set $path_info $3;
    }
    location /docs/ {
    alias /usr/local/share/doc/bugzilla/;
    }
    }
  2. petr999 revised this gist Jan 19, 2010. 1 changed file with 8 additions and 3 deletions.
    11 changes: 8 additions & 3 deletions gistfile3.PL
    Original file line number Diff line number Diff line change
    @@ -31,11 +31,16 @@ undef $FCGI::Spawn::fcgi;

    # Bugzilla.pm is imported for request cache and database handle cleaning
    our %SAVE_ENV = %ENV; eval " use Bugzilla; " ; die $@ if $@; %ENV = %SAVE_ENV; undef %SAVE_ENV;
    # to drop out database handles before fork()s, somewhy $_request_cache is undef()'d
    #
    # You need one of two those lines below to keep from errors on fork()ed database
    # handles those known not to work after the fork().
    #
    # with mysql, auto_reconnect feature is useful for persistent forks. You may not have
    # such an option for other DBD/DBMS software.
    eval 'Bugzilla->dbh->{mysql_auto_reconnect} = 1;' ; die $@ if $@;
    # This is to drop out database handles before fork()s, somewhy $_request_cache is undef()'d
    # in Bugzilla::_cleanup, need to define it after that.
    eval 'Bugzilla::_cleanup; $Bugzilla::_request_cache={};' ; die $@ if $@;
    # with mysql, auto_reconnect feature is useful for persistent forks.
    eval 'Bugzilla->dbh->{mysql_auto_reconnect} = 1;' ; die $@ if $@;

    # ...
    $spawn->spawn();
  3. petr999 revised this gist Jan 19, 2010. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion gistfile3.PL
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ sub the_callout {
    }

    # ...
    FCGI::Spawn->new
    my $spawn = FCGI::Spawn->new();
    # ...

    # to import modules for sharing afterwards
    @@ -36,3 +36,7 @@ our %SAVE_ENV = %ENV; eval " use Bugzilla; " ; die $@ if $@; %ENV = %SAVE_ENV;
    eval 'Bugzilla::_cleanup; $Bugzilla::_request_cache={};' ; die $@ if $@;
    # with mysql, auto_reconnect feature is useful for persistent forks.
    eval 'Bugzilla->dbh->{mysql_auto_reconnect} = 1;' ; die $@ if $@;

    # ...
    $spawn->spawn();
    # ...
  4. petr999 revised this gist Jan 19, 2010. 1 changed file with 23 additions and 1 deletion.
    24 changes: 23 additions & 1 deletion gistfile3.PL
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    # this is to be used in conjunction with
    # clean_inc_subnamespace => 'Bugzilla::Config'
    # and the new save_env feature

    # to avoid fork exiting after max_requests put this into the
    # BEGIN{
    # ...
    @@ -13,4 +17,22 @@ sub the_callout {
    # clean_inc_subnamespace => 'Bugzilla::Config'}
    # in the FCGI::Spawn->new(); and config is
    # to be re-read on each request
    }
    }

    # ...
    FCGI::Spawn->new
    # ...

    # to import modules for sharing afterwards
    map {
    $FCGI::Spawn::fcgi = new CGI; $spawn->callout( $_, $FCGI::Spawn::fcgi ) ; undef $CGI::Q;
    }( $webguiRoot.'/../www/index.pl', $bugzillaRoot.'/index.cgi', );
    undef $FCGI::Spawn::fcgi;

    # Bugzilla.pm is imported for request cache and database handle cleaning
    our %SAVE_ENV = %ENV; eval " use Bugzilla; " ; die $@ if $@; %ENV = %SAVE_ENV; undef %SAVE_ENV;
    # to drop out database handles before fork()s, somewhy $_request_cache is undef()'d
    # in Bugzilla::_cleanup, need to define it after that.
    eval 'Bugzilla::_cleanup; $Bugzilla::_request_cache={};' ; die $@ if $@;
    # with mysql, auto_reconnect feature is useful for persistent forks.
    eval 'Bugzilla->dbh->{mysql_auto_reconnect} = 1;' ; die $@ if $@;
  5. petr999 revised this gist Jan 17, 2010. 1 changed file with 16 additions and 0 deletions.
    16 changes: 16 additions & 0 deletions gistfile3.PL
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # to avoid fork exiting after max_requests put this into the
    # BEGIN{
    # ...
    *CORE::GLOBAL::exit = sub {
    last CALLED_OUT;
    }
    # ...
    #}

    sub the_callout {
    do shift;
    CALLED_OUT: $Bugzilla::_request_cache = {}; # to be used with
    # clean_inc_subnamespace => 'Bugzilla::Config'}
    # in the FCGI::Spawn->new(); and config is
    # to be re-read on each request
    }
  6. petr999 created this gist Jan 16, 2010.
    20 changes: 20 additions & 0 deletions gistfile1.diff
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    --- bugzilla.orig/Bugzilla/CGI.pm 2010-01-09 20:39:11.000000000 +0400
    +++ bugzilla/Bugzilla/CGI.pm 2010-01-12 00:02:14.811537343 +0400
    @@ -35,7 +35,7 @@

    use CGI qw(-no_xhtml -oldstyle_urls :private_tempfiles :unique_headers SERVER_PUSH);

    -use base qw(CGI);
    +use base qw(CGI::Fast);

    use Bugzilla::Constants;
    use Bugzilla::Error;
    @@ -63,7 +63,7 @@
    my ($invocant, @args) = @_;
    my $class = ref($invocant) || $invocant;

    - my $self = $class->SUPER::new(@args);
    + my $self = bless new CGI, $class;

    # Make sure our outgoing cookie list is empty on each invocation
    $self->{Bugzilla_cookie_list} = [];
    4 changes: 4 additions & 0 deletions gistfile2.PL
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    sub the_callout {
    do shift;
    map{ delete Bugzilla->request_cache->{$_} } grep { $_ ne 'params' } keys %{ Bugzilla->request_cache };
    }