From d831a869fc4f54a31f1e90d86b6cadb3212af8f7 Mon Sep 17 00:00:00 2001 From: Daniel Kerwin Date: Wed, 12 Mar 2014 18:17:41 +0100 Subject: [PATCH 1/2] Add setting worker_rlimit_nofile with default of 1024 --- manifests/config.pp | 1 + manifests/init.pp | 5 +++++ manifests/params.pp | 1 + templates/conf.d/nginx.conf.erb | 1 + 4 files changed, 8 insertions(+) diff --git a/manifests/config.pp b/manifests/config.pp index acae8de44..fb3ed4bb9 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -16,6 +16,7 @@ class nginx::config( $worker_processes = $nginx::params::nx_worker_processes, $worker_connections = $nginx::params::nx_worker_connections, + $worker_rlimit_nofile = $nginx::params::nx_worker_rlimit_nofile, $confd_purge = $nginx::params::nx_confd_purge, $vhost_purge = $nginx::params::nx_vhost_purge, $server_tokens = $nginx::params::nx_server_tokens, diff --git a/manifests/init.pp b/manifests/init.pp index 05b9c0497..a33512a02 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -31,6 +31,7 @@ class nginx ( $worker_processes = $nginx::params::nx_worker_processes, $worker_connections = $nginx::params::nx_worker_connections, + $worker_rlimit_nofile = $nginx::params::nx_worker_rlimit_nofile, $package_name = $nginx::params::package_name, $package_ensure = $nginx::params::package_ensure, $package_source = $nginx::params::package_source, @@ -70,6 +71,9 @@ if (!is_integer($worker_connections)) { fail('$worker_connections must be an integer.') } + if (!is_integer($worker_rlimit_nofile)) { + fail('$worker_rlimit_nofile must be an integer.') + } validate_string($package_name) validate_string($package_ensure) validate_string($package_source) @@ -120,6 +124,7 @@ class { 'nginx::config': worker_processes => $worker_processes, worker_connections => $worker_connections, + worker_rlimit_nofile => $worker_rlimit_nofile, proxy_set_header => $proxy_set_header, proxy_http_version => $proxy_http_version, proxy_cache_path => $proxy_cache_path, diff --git a/manifests/params.pp b/manifests/params.pp index a669d910c..7e80cb59a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -27,6 +27,7 @@ $nx_vhost_purge = false $nx_worker_processes = 1 $nx_worker_connections = 1024 + $nx_worker_rlimit_nofile = 1024 $nx_types_hash_max_size = 1024 $nx_types_hash_bucket_size = 512 $nx_names_hash_bucket_size = 64 diff --git a/templates/conf.d/nginx.conf.erb b/templates/conf.d/nginx.conf.erb index 1b8502e5c..68437865b 100644 --- a/templates/conf.d/nginx.conf.erb +++ b/templates/conf.d/nginx.conf.erb @@ -1,5 +1,6 @@ user <%= scope.lookupvar('nginx::config::nx_daemon_user') %>; worker_processes <%= @worker_processes %>; +worker_rlimit_nofile <%= @worker_rlimit_nofile %>; error_log <%= @nginx_error_log %>; pid <%= scope.lookupvar('nginx::params::nx_pid')%>; From 04b6c3dd7d73bf28a256624fdbb86b3dddcb31d2 Mon Sep 17 00:00:00 2001 From: Daniel Kerwin Date: Wed, 12 Mar 2014 18:41:03 +0100 Subject: [PATCH 2/2] Test worker_rlimit_nofile --- spec/classes/config_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index 6ebb53138..6076e5481 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -161,6 +161,12 @@ :value => '4', :match => 'worker_processes 4;', }, + { + :title => 'should set worker_rlimit_nofile', + :attr => 'worker_rlimit_nofile', + :value => '10000', + :match => 'worker_rlimit_nofile 10000;', + }, { :title => 'should set error_log', :attr => 'nginx_error_log',