Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WSGIApplicationGroup and WSGIImportScript directives #606

Merged
merged 2 commits into from
Feb 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,13 @@ To set up a virtual host with WSGI
apache::vhost { 'wsgi.example.com':
port => '80',
docroot => '/var/www/pythonapp',
wsgi_application_group => '%{GLOBAL}',
wsgi_daemon_process => 'wsgi',
wsgi_daemon_process_options =>
{ processes => '2', threads => '15', display-name => '%{GROUP}' },
wsgi_import_script => '/var/www/demo.wsgi',
wsgi_import_script_options =>
{ process-group => 'wsgi', application-group => '%{GLOBAL}' },
wsgi_process_group => 'wsgi',
wsgi_script_aliases => { '/' => '/var/www/demo.wsgi' },
}
Expand Down
8 changes: 8 additions & 0 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,11 @@
$setenvif = [],
$block = [],
$ensure = 'present',
$wsgi_application_group = undef,
$wsgi_daemon_process = undef,
$wsgi_daemon_process_options = undef,
$wsgi_import_script = undef,
$wsgi_import_script_options = undef,
$wsgi_process_group = undef,
$wsgi_script_aliases = undef,
$custom_fragment = undef,
Expand Down Expand Up @@ -209,6 +212,9 @@
if $wsgi_daemon_process_options {
validate_hash($wsgi_daemon_process_options)
}
if $wsgi_import_script_options {
validate_hash($wsgi_import_script_options)
}
if $itk {
validate_hash($itk)
}
Expand Down Expand Up @@ -495,7 +501,9 @@
# - $suphp_engine
# - $suphp_configpath
# wsgi fragment:
# - $wsgi_application_group
# - $wsgi_daemon_process
# - $wsgi_import_script
# - $wsgi_process_group
# - $wsgi_script_aliases
file { "${priority_real}-${filename}.conf":
Expand Down
5 changes: 5 additions & 0 deletions spec/acceptance/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,11 @@ class { 'apache::mod::wsgi': }
host { 'test.server': ip => '127.0.0.1' }
apache::vhost { 'test.server':
docroot => '/tmp',
wsgi_application_group => '%{GLOBAL}',
wsgi_daemon_process => 'wsgi',
wsgi_daemon_process_options => {processes => '2'},
wsgi_import_script => '/test1',
wsgi_import_script_options => { application-group => '%{GLOBAL}', process-group => 'wsgi' },
wsgi_process_group => 'vagrant',
wsgi_script_aliases => { '/test' => '/test1' },
}
Expand All @@ -882,7 +885,9 @@ class { 'apache::mod::wsgi': }

describe file("#{$vhost_dir}/25-test.server.conf") do
it { should be_file }
it { should contain 'WSGIApplicationGroup %{GLOBAL}' }
it { should contain 'WSGIDaemonProcess wsgi processes=2' }
it { should contain 'WSGIImportScript /test1 application-group=%{GLOBAL} process-group=wsgi' }
it { should contain 'WSGIProcessGroup vagrant' }
it { should contain 'WSGIScriptAlias /test "/test1"' }
end
Expand Down
18 changes: 18 additions & 0 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,12 @@
/^ WSGIScriptAlias \/ "\/usr\/local\/wsgi\/scripts\/myapp.wsgi"$/,
],
},
{
:title => 'should accept a wsgi application group',
:attr => 'wsgi_application_group',
:value => '%{GLOBAL}',
:match => [/^ WSGIApplicationGroup %{GLOBAL}$/],
},
{
:title => 'should contain environment variables',
:attr => 'access_log_env_var',
Expand Down Expand Up @@ -1116,6 +1122,18 @@
end
end

describe 'when wsgi_import_script and wsgi_import_script_options are specified' do
let :params do default_params.merge({
:wsgi_import_script => '/var/www/demo.wsgi',
:wsgi_import_script_options => { 'application-group' => '%{GLOBAL}', 'process-group' => 'wsgi' },
}) end
it 'should set wsgi_import_script_options' do
should contain_file("25-#{title}.conf").with_content(
/^ WSGIImportScript \/var\/www\/demo.wsgi application-group=%{GLOBAL} process-group=wsgi$/
)
end
end

describe 'when rewrites are specified' do
let :params do default_params.merge({
:rewrites => [
Expand Down
6 changes: 6 additions & 0 deletions templates/vhost/_wsgi.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<% if @wsgi_application_group -%>
WSGIApplicationGroup <%= @wsgi_application_group %>
<% end -%>
<% if @wsgi_daemon_process and @wsgi_daemon_process_options -%>
WSGIDaemonProcess <%= @wsgi_daemon_process %> <%= @wsgi_daemon_process_options.collect { |k,v| "#{k}=#{v}"}.sort.join(' ') %>
<% elsif @wsgi_daemon_process and !@wsgi_daemon_process_options -%>
WSGIDaemonProcess <%= @wsgi_daemon_process %>
<% end -%>
<% if @wsgi_import_script and @wsgi_import_script_options -%>
WSGIImportScript <%= @wsgi_import_script %> <%= @wsgi_import_script_options.collect { |k,v| "#{k}=#{v}"}.sort.join(' ') %>
<% end -%>
<% if @wsgi_process_group -%>
WSGIProcessGroup <%= @wsgi_process_group %>
<% end -%>
Expand Down