Skip to content

Commit

Permalink
Allow passing Passenger parameters to directories
Browse files Browse the repository at this point in the history
A bunch of parameters can be set on a virtual host, but also
directories.  This allows to build complex setups composed of multiple
applications available through a single VirtualHost.
  • Loading branch information
smortex committed Apr 17, 2018
1 parent ad461a8 commit 7c1747f
Show file tree
Hide file tree
Showing 2 changed files with 335 additions and 2 deletions.
225 changes: 225 additions & 0 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,46 @@
'dav' => 'filesystem',
'dav_depth_infinity' => true,
'dav_min_timeout' => '600' },
{
'path' => '/var/www/node-app/public',
'passenger_enabled' => true,
'passenger_base_uri' => '/app',
'passenger_ruby' => '/path/to/ruby',
'passenger_python' => '/path/to/python',
'passenger_nodejs' => '/path/to/nodejs',
'passenger_meteor_app_settings' => '/path/to/file.json',
'passenger_app_env' => 'demo',
'passenger_app_root' => '/var/www/node-app',
'passenger_app_group_name' => 'foo_bar',
'passenger_app_type' => 'node',
'passenger_startup_file' => 'start.js',
'passenger_restart_dir' => 'temp',
'passenger_load_shell_envvars' => false,
'passenger_rolling_restarts' => false,
'passenger_resist_deployment_errors' => false,
'passenger_user' => 'nodeuser',
'passenger_group' => 'nodegroup',
'passenger_friendly_error_pages' => true,
'passenger_min_instances' => 7,
'passenger_max_instances' => 9,
'passenger_force_max_concurrent_requests_per_process' => 12,
'passenger_start_timeout' => 10,
'passenger_concurrency_model' => 'thread',
'passenger_thread_count' => 20,
'passenger_max_requests' => 2000,
'passenger_max_request_time' => 1,
'passenger_memory_limit' => 32,
'passenger_high_performance' => false,
'passenger_buffer_upload' => false,
'passenger_buffer_response' => false,
'passenger_error_override' => false,
'passenger_max_request_queue_size' => 120,
'passenger_max_request_queue_time' => 5,
'passenger_sticky_sessions' => true,
'passenger_sticky_sessions_cookie_name' => '_delicious_cookie',
'passenger_allow_encoded_slashes' => false,
'passenger_debugger' => false,
},
],
'error_log' => false,
'error_log_file' => 'httpd_error_log',
Expand Down Expand Up @@ -676,6 +716,191 @@
content: %r{^\s+DavMinTimeout\s600$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerEnabled\sOn$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerBaseURI\s/app$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerRuby\s/path/to/ruby$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerPython\s/path/to/python$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerNodejs\s/path/to/nodejs$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerMeteorAppSettings\s/path/to/file\.json$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerAppEnv\sdemo$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerAppRoot\s/var/www/node-app$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerAppGroupName\sfoo_bar$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerAppType\snode$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerStartupFile\sstart\.js$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerRestartDir\stemp$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerLoadShellEnvvars\sOff$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerRollingRestarts\sOff$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerResistDeploymentErrors\sOff$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerUser\snodeuser$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerGroup\snodegroup$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerFriendlyErrorPages\sOn$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerMinInstances\s7$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerMaxInstances\s9$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerForceMaxConcurrentRequestsPerProcess\s12$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerStartTimeout\s10$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerConcurrencyModel\sthread$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerThreadCount\s20$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerMaxRequests\s2000$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerMaxRequestTime\s1$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerMemoryLimit\s32$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerHighPerformance\sOff$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerBufferUpload\sOff$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerBufferResponse\sOff$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerErrorOverride\sOff$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerMaxRequestQueueSize\s120$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerMaxRequestQueueTime\s5$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerStickySessions\sOn$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerStickySessionsCookieName\s_delicious_cookie$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerAllowEncodedSlashes\sOff$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+PassengerDebugger\sOff$},
)
}
it { is_expected.to contain_concat__fragment('rspec.example.com-additional_includes') }
it { is_expected.to contain_concat__fragment('rspec.example.com-logging') }
it { is_expected.to contain_concat__fragment('rspec.example.com-serversignature') }
Expand Down
112 changes: 110 additions & 2 deletions templates/vhost/_directories.erb
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,116 @@
<%- if directory['sethandler'] and directory['sethandler'] != '' -%>
SetHandler <%= directory['sethandler'] %>
<%- end -%>
<%- if directory['passenger_enabled'] and directory['passenger_enabled'] != '' -%>
PassengerEnabled <%= directory['passenger_enabled'] %>
<%- unless directory['passenger_enabled'].nil? -%>
PassengerEnabled <%= scope.call_function('apache::bool2httpd', [directory['passenger_enabled']]) %>
<%- end -%>
<%- if directory['passenger_base_uri'] and ! directory['passenger_base_uri'].empty? -%>
PassengerBaseURI <%= directory['passenger_base_uri'] %>
<%- end -%>
<%- if directory['passenger_ruby'] and ! directory['passenger_ruby'].empty? -%>
PassengerRuby <%= directory['passenger_ruby'] %>
<%- end -%>
<%- if directory['passenger_python'] and ! directory['passenger_python'].empty? -%>
PassengerPython <%= directory['passenger_python'] %>
<%- end -%>
<%- if directory['passenger_nodejs'] and ! directory['passenger_nodejs'].empty? -%>
PassengerNodejs <%= directory['passenger_nodejs'] %>
<%- end -%>
<%- if directory['passenger_meteor_app_settings'] and ! directory['passenger_meteor_app_settings'].empty? -%>
PassengerMeteorAppSettings <%= directory['passenger_meteor_app_settings'] %>
<%- end -%>
<%- if directory['passenger_app_env'] and ! directory['passenger_app_env'].empty? -%>
PassengerAppEnv <%= directory['passenger_app_env'] %>
<%- end -%>
<%- if directory['passenger_app_root'] and ! directory['passenger_app_root'].empty? -%>
PassengerAppRoot <%= directory['passenger_app_root'] %>
<%- end -%>
<%- if directory['passenger_app_group_name'] and ! directory['passenger_app_group_name'].empty? -%>
PassengerAppGroupName <%= directory['passenger_app_group_name'] %>
<%- end -%>
<%- if directory['passenger_app_type'] and ! directory['passenger_app_type'].empty? -%>
PassengerAppType <%= directory['passenger_app_type'] %>
<%- end -%>
<%- if directory['passenger_startup_file'] and ! directory['passenger_startup_file'].empty? -%>
PassengerStartupFile <%= directory['passenger_startup_file'] %>
<%- end -%>
<%- if directory['passenger_restart_dir'] and ! directory['passenger_restart_dir'].empty? -%>
PassengerRestartDir <%= directory['passenger_restart_dir'] %>
<%- end -%>
<%- unless directory['passenger_load_shell_envvars'].nil? -%>
PassengerLoadShellEnvvars <%= scope.call_function('apache::bool2httpd', [directory['passenger_load_shell_envvars']]) %>
<%- end -%>
<%- unless directory['passenger_rolling_restarts'].nil? -%>
PassengerRollingRestarts <%= scope.call_function('apache::bool2httpd', [directory['passenger_rolling_restarts']]) %>
<%- end -%>
<%- unless directory['passenger_resist_deployment_errors'].nil? -%>
PassengerResistDeploymentErrors <%= scope.call_function('apache::bool2httpd', [directory['passenger_resist_deployment_errors']]) %>
<%- end -%>
<%- if directory['passenger_user'] and ! directory['passenger_user'].empty? -%>
PassengerUser <%= directory['passenger_user'] %>
<%- end -%>
<%- if directory['passenger_group'] and ! directory['passenger_group'].empty? -%>
PassengerGroup <%= directory['passenger_group'] %>
<%- end -%>
<%- unless directory['passenger_friendly_error_pages'].nil? -%>
PassengerFriendlyErrorPages <%= scope.call_function('apache::bool2httpd', [directory['passenger_friendly_error_pages']]) %>
<%- end -%>
<%- unless directory['passenger_min_instances'].nil? -%>
PassengerMinInstances <%= directory['passenger_min_instances'] %>
<%- end -%>
<%- unless directory['passenger_max_instances'].nil? -%>
PassengerMaxInstances <%= directory['passenger_max_instances'] %>
<%- end -%>
<%- unless directory['passenger_force_max_concurrent_requests_per_process'].nil? -%>
PassengerForceMaxConcurrentRequestsPerProcess <%= directory['passenger_force_max_concurrent_requests_per_process'] %>
<%- end -%>
<%- unless directory['passenger_start_timeout'].nil? -%>
PassengerStartTimeout <%= directory['passenger_start_timeout'] %>
<%- end -%>
<%- if directory['passenger_concurrency_model'] and ! directory['passenger_concurrency_model'].empty? -%>
PassengerConcurrencyModel <%= directory['passenger_concurrency_model'] %>
<%- end -%>
<%- unless directory['passenger_thread_count'].nil? -%>
PassengerThreadCount <%= directory['passenger_thread_count'] %>
<%- end -%>
<%- unless directory['passenger_max_requests'].nil? -%>
PassengerMaxRequests <%= directory['passenger_max_requests'] %>
<%- end -%>
<%- unless directory['passenger_max_request_time'].nil? -%>
PassengerMaxRequestTime <%= directory['passenger_max_request_time'] %>
<%- end -%>
<%- unless directory['passenger_memory_limit'].nil? -%>
PassengerMemoryLimit <%= directory['passenger_memory_limit'] %>
<%- end -%>
<%- unless directory['passenger_high_performance'].nil? -%>
PassengerHighPerformance <%= scope.call_function('apache::bool2httpd', [directory['passenger_high_performance']]) %>
<%- end -%>
<%- unless directory['passenger_buffer_upload'].nil? -%>
PassengerBufferUpload <%= scope.call_function('apache::bool2httpd', [directory['passenger_buffer_upload']]) %>
<%- end -%>
<%- unless directory['passenger_buffer_response'].nil? -%>
PassengerBufferResponse <%= scope.call_function('apache::bool2httpd', [directory['passenger_buffer_response']]) %>
<%- end -%>
<%- unless directory['passenger_error_override'].nil? -%>
PassengerErrorOverride <%= scope.call_function('apache::bool2httpd', [directory['passenger_error_override']]) %>
<%- end -%>
<%- unless directory['passenger_max_request_queue_size'].nil? -%>
PassengerMaxRequestQueueSize <%= directory['passenger_max_request_queue_size'] %>
<%- end -%>
<%- unless directory['passenger_max_request_queue_time'].nil? -%>
PassengerMaxRequestQueueTime <%= directory['passenger_max_request_queue_time'] %>
<%- end -%>
<%- unless directory['passenger_sticky_sessions'].nil? -%>
PassengerStickySessions <%= scope.call_function('apache::bool2httpd', [directory['passenger_sticky_sessions']]) %>
<%- end -%>
<%- if directory['passenger_sticky_sessions_cookie_name'] and ! directory['passenger_sticky_sessions_cookie_name'].empty? -%>
PassengerStickySessionsCookieName <%= directory['passenger_sticky_sessions_cookie_name'] %>
<%- end -%>
<%- unless directory['passenger_allow_encoded_slashes'].nil? -%>
PassengerAllowEncodedSlashes <%= scope.call_function('apache::bool2httpd', [directory['passenger_allow_encoded_slashes']]) %>
<%- end -%>
<%- unless directory['passenger_debugger'].nil? -%>
PassengerDebugger <%= scope.call_function('apache::bool2httpd', [directory['passenger_debugger']]) %>
<%- end -%>
<%- if directory['php_flags'] and ! directory['php_flags'].empty? -%>
<%- directory['php_flags'].sort.each do |flag,value| -%>
Expand Down

0 comments on commit 7c1747f

Please sign in to comment.