Firefox-Marionette

 view release on metacpan or  search on metacpan

t/test_daemons.pm  view on Meta::CPAN

            print {$index_handle} $random_string
              or Carp::croak(
                "Failed to write to $index_file_path:$EXTENDED_OS_ERROR");
            close $index_handle
              or Carp::croak(
                "Failed to close $index_file_path:$EXTENDED_OS_ERROR");
        }
    }
    my $pid_path =
      File::Spec->catfile( $base_directory->dirname(), 'nginx.pid' );
    my $pid_handle = FileHandle->new(
        $pid_path,
        Fcntl::O_WRONLY() | Fcntl::O_EXCL() | Fcntl::O_CREAT(),
        Fcntl::S_IRUSR() | Fcntl::S_IWUSR()
    ) or Carp::croak("Failed to open $pid_path:$EXTENDED_OS_ERROR");
    my $config_path =
      File::Spec->catfile( $base_directory->dirname(), 'nginx.conf' );
    my $log_directory =
      File::Spec->catdir( $base_directory->dirname(), 'logs' );
    mkdir $log_directory, Fcntl::S_IRWXU()
      or Carp::croak("Failed to mkdir $log_directory:$EXTENDED_OS_ERROR");
    my $error_log_path = File::Spec->catfile( $log_directory, 'error.log' );
    my $access_log_path =
      File::Spec->catfile( $base_directory->dirname(), 'access.log' );
    my $config_handle = FileHandle->new(
        $config_path,
        Fcntl::O_WRONLY() | Fcntl::O_EXCL() | Fcntl::O_CREAT(),
        Fcntl::S_IRUSR() | Fcntl::S_IWUSR()
    ) or Carp::croak("Failed to open $config_path:$EXTENDED_OS_ERROR");
    my %temp_directories;

    foreach my $name (
        qw(client_body_temp proxy_temp fastcgi_temp uwsgi_temp scgi_temp))
    {
        $temp_directories{$name} =
          File::Spec->catfile( $base_directory->dirname(), $name );
        mkdir $temp_directories{$name}, Fcntl::S_IRWXU()
          or Carp::croak(
            "Failed to mkdir $temp_directories{$name}:$EXTENDED_OS_ERROR");
    }
    print {$config_handle}
      <<"_NGINX_CONF_" or Carp::croak("Failed to write to temporary file:$EXTENDED_OS_ERROR");
daemon off;
pid $pid_path;
error_log logs/error.log;

events {
    worker_connections 1024;
}

http {
    client_body_temp_path   $temp_directories{client_body_temp};
    proxy_temp_path         $temp_directories{proxy_temp};
    fastcgi_temp_path       $temp_directories{fastcgi_temp};
    uwsgi_temp_path         $temp_directories{uwsgi_temp};
    scgi_temp_path          $temp_directories{scgi_temp};
    access_log              logs/access.log;
    sendfile                on;
    tcp_nopush              on;
    tcp_nodelay             on;
    keepalive_timeout       65;
    types_hash_max_size     4096;

    types {
        text/html           html;
        text/javascript     js;
        text/css            css;
        application/json    json;
    }
    default_type            text/plain;

    server  {
_NGINX_CONF_
    if ( $key_size && $ca ) {
        print {$config_handle}
          <<"_NGINX_CONF_" or Carp::croak("Failed to write to temporary file:$EXTENDED_OS_ERROR");
        listen                     $listen:$port ssl;
_NGINX_CONF_
    }
    else {
        print {$config_handle}
          <<"_NGINX_CONF_" or Carp::croak("Failed to write to temporary file:$EXTENDED_OS_ERROR");
        listen                     $listen:$port;
_NGINX_CONF_
    }
    print {$config_handle}
      <<"_NGINX_CONF_" or Carp::croak("Failed to write to temporary file:$EXTENDED_OS_ERROR");
        server_name                default;
_NGINX_CONF_
    if ( $username || $password ) {
        print {$config_handle}
          <<"_NGINX_CONF_" or Carp::croak("Failed to write to temporary file:$EXTENDED_OS_ERROR");
        auth_basic                 "$realm";
        auth_basic_user_file       $passwd_path;
_NGINX_CONF_
    }
    if ( $key_size && $ca ) {
        print {$config_handle}
          <<"_NGINX_CONF_" or Carp::croak("Failed to write to temporary file:$EXTENDED_OS_ERROR");
        ssl_certificate            $certificate_path;
        ssl_certificate_key        $key_path;
        ssl_protocols              TLSv1.2;
        ssl_ciphers                ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:!AES128-SHA:!DES-CBC3-SHA:!MD5:!aNULL:!CAMELLIA:!PSK:!SRP;
        ssl_prefer_server_ciphers  on;
        ssl_session_cache          shared:SSL:10m;
        ssl_session_timeout        10m;
        ssl_stapling               off;
        ssl_stapling_verify        off;
        ssl_ecdh_curve             secp384r1;
_NGINX_CONF_
    }
    print {$config_handle}
      <<"_NGINX_CONF_" or Carp::croak("Failed to write to temporary file:$EXTENDED_OS_ERROR");
        server_tokens              off;
        root                       $root_name;
        index                      $index_name;
    }
}
_NGINX_CONF_
    close $config_handle
      or Carp::croak("Failed to close $config_path:$EXTENDED_OS_ERROR");



( run in 0.782 second using v1.01-cache-2.11-cpan-ceb78f64989 )