Skip to content
Browse files

Test.pm: automatically injecting defaults into nginx-perl.conf if not…

… present
  • Loading branch information...
1 parent c9adb03 commit f21d9784ba24ad3ac5048c1156dc72bcb4f07b77 @zzzcpan committed Apr 30, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 src/http/modules/perl/Test.pm
View
17 src/http/modules/perl/Test.pm
@@ -321,6 +321,23 @@ sub prepare_nginx_dir_die {
# injecting proper @INC
$conf =~ s/(\s+http\s*{)/$1\n$incs\n/gs;
+ # injecting testing defaults
+ if ($conf !~ /events/) {
+ $conf = "events { worker_connections 128; }\n$conf";
+ }
+ if ($conf !~ /error_log/) {
+ $conf = "error_log logs/error.log debug;\n$conf";
+ }
+ if ($conf !~ /master_process/) {
+ $conf = "master_process off;\n$conf";
+ }
+ if ($conf !~ /daemon/) {
+ $conf = "daemon off;\n$conf";
+ }
+ if ($conf !~ /worker_processes/) {
+ $conf = "worker_processes 1;\n$conf";
+ }
+
open my $fh, '>', "$dir/conf/nginx-perl.conf"
or die "Cannot open file '$dir/conf/nginx-perl.conf' " .
"for writing: $!";

0 comments on commit f21d978

Please sign in to comment.
Something went wrong with that request. Please try again.