Skip to content

Commit

Permalink
Merge pull request #894 from domcleal/vhost-passenger
Browse files Browse the repository at this point in the history
Add Passenger related parameters to vhost
  • Loading branch information
igalic committed Oct 17, 2014
2 parents 6300be8 + 5278807 commit bb7ee1a
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,26 @@ Sets the [Options](http://httpd.apache.org/docs/current/mod/core.html#options) f

Sets the overrides for the specified virtual host. Accepts an array of [AllowOverride](http://httpd.apache.org/docs/current/mod/core.html#allowoverride) arguments. Defaults to '[none]'.

#####`passenger_app_root`

Sets [PassengerRoot](https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#PassengerAppRoot), the location of the Passenger application root if different from the DocumentRoot.

#####`passenger_ruby`

Sets [PassengerRuby](https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#PassengerRuby) on this virtual host, the Ruby interpreter to use for the application.

#####`passenger_min_instances`

Sets [PassengerMinInstances](https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#PassengerMinInstances), the minimum number of application processes to run.

#####`passenger_start_timeout`

Sets [PassengerStartTimeout](https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#_passengerstarttimeout_lt_seconds_gt), the timeout for the application startup.

#####`passenger_pre_start`

Sets [PassengerPreStart](https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#PassengerPreStart), the URL of the application if pre-starting is required.

#####`php_admin_flags & values`

Allows per-vhost setting [`php_admin_value`s or `php_admin_flag`s](http://php.net/manual/en/configuration.changes.php). These flags or values cannot be overwritten by a user or an application. Defaults to '[]'.
Expand Down
21 changes: 21 additions & 0 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@
$apache_version = $::apache::apache_version,
$allow_encoded_slashes = undef,
$suexec_user_group = undef,
$passenger_app_root = undef,
$passenger_ruby = undef,
$passenger_min_instances = undef,
$passenger_start_timeout = undef,
$passenger_pre_start = undef,
) {
# The base class must be included first because it is used by parameter defaults
if ! defined(Class['apache']) {
Expand Down Expand Up @@ -211,6 +216,10 @@
include ::apache::mod::suexec
}

if $passenger_app_root or $passenger_ruby or $passenger_min_instances or $passenger_start_timeout or $passenger_pre_start {
include ::apache::mod::passenger
}

# Configure the defaultness of a vhost
if $priority {
$priority_real = $priority
Expand Down Expand Up @@ -779,6 +788,18 @@
}
}

# Template uses:
# - $passenger_app_root
# - $passenger_ruby
# - $passenger_min_instances
# - $passenger_start_timeout
# - $passenger_pre_start
concat::fragment { "${name}-passenger":
target => "${priority_real}-${filename}.conf",
order => 290,
content => template('apache/vhost/_passenger.erb'),
}

# Template uses no variables
concat::fragment { "${name}-file_footer":
target => "${priority_real}-${filename}.conf",
Expand Down
10 changes: 9 additions & 1 deletion spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,12 @@
'additional_includes' => '/custom/path/includes',
'apache_version' => '2.4',
'suexec_user_group' => 'root root',
'allow_encoded_slashes' => 'nodecode'
'allow_encoded_slashes' => 'nodecode',
'passenger_app_root' => '/usr/share/myapp',
'passenger_ruby' => '/usr/bin/ruby1.9.1',
'passenger_min_instances' => '1',
'passenger_start_timeout' => '600',
'passenger_pre_start' => 'http://localhost/myapp'
}
end
let :facts do
Expand All @@ -256,6 +261,7 @@
it { is_expected.to contain_class('apache::mod::vhost_alias') }
it { is_expected.to contain_class('apache::mod::wsgi') }
it { is_expected.to contain_class('apache::mod::suexec') }
it { is_expected.to contain_class('apache::mod::passenger') }
it { is_expected.to contain_file('/var/www/logs').with({
'ensure' => 'directory',
'mode' => '0600',
Expand Down Expand Up @@ -305,6 +311,7 @@
it { is_expected.to contain_concat__fragment('rspec.example.com-custom_fragment') }
it { is_expected.to contain_concat__fragment('rspec.example.com-fastcgi') }
it { is_expected.to contain_concat__fragment('rspec.example.com-suexec') }
it { is_expected.to contain_concat__fragment('rspec.example.com-passenger') }
it { is_expected.to contain_concat__fragment('rspec.example.com-file_footer') }
end
context 'not everything can be set together...' do
Expand Down Expand Up @@ -337,6 +344,7 @@
it { is_expected.to_not contain_class('apache::mod::mime') }
it { is_expected.to_not contain_class('apache::mod::vhost_alias') }
it { is_expected.to_not contain_class('apache::mod::wsgi') }
it { is_expected.to_not contain_class('apache::mod::passenger') }
it { is_expected.to_not contain_class('apache::mod::suexec') }
it { is_expected.to_not contain_class('apache::mod::rewrite') }
it { is_expected.to contain_class('apache::mod::alias') }
Expand Down
15 changes: 15 additions & 0 deletions templates/vhost/_passenger.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<% if @passenger_app_root -%>
PassengerAppRoot <%= @passenger_app_root %>
<% end -%>
<% if @passenger_ruby -%>
PassengerRuby <%= @passenger_ruby %>
<% end -%>
<% if @passenger_min_instances -%>
PassengerMinInstances <%= @passenger_min_instances %>
<% end -%>
<% if @passenger_start_timeout -%>
PassengerStartTimeout <%= @passenger_start_timeout %>
<% end -%>
<% if @passenger_pre_start -%>
PassengerPreStart <%= @passenger_pre_start %>
<% end -%>

0 comments on commit bb7ee1a

Please sign in to comment.