Skip to content

Commit

Permalink
Merge pull request #1034 from liff/ticket/1776-add_passenger_app_env
Browse files Browse the repository at this point in the history
Add support for Passenger's PassengerAppEnv setting
  • Loading branch information
Morgan Haskel committed Feb 23, 2015
2 parents 1615834 + cfc2846 commit 016c0c7
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,10 @@ Sets the overrides for the specified virtual host. Accepts an array of [AllowOve

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_app_env`

Sets [PassengerAppEnv](https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#PassengerAppEnv), the environment for the Passenger application. If not specifies, defaults to the global setting or 'production'.

#####`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.
Expand Down
8 changes: 8 additions & 0 deletions README.passenger.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ Allows toggling of PassengerUseGlobalQueue. NOTE: PassengerUseGlobalQueue is
the default in Passenger 4.x and the versions >= 4.x have disabled this
configuration option altogether. Use with caution.

### passenger_app_env

Sets the global default `PassengerAppEnv` for Passenger applications. Not set by
default (`undef`) and thus defaults to Passenger's built-in value of 'production'.
This directive can be overridden in an `apache::vhost` resource.

https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#PassengerAppEnv

## Parameters used to load the module

Unlike the tuning parameters specified above, the following parameters are only
Expand Down
2 changes: 2 additions & 0 deletions manifests/mod/passenger.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
$passenger_default_ruby = $::apache::params::passenger_default_ruby,
$passenger_max_pool_size = undef,
$passenger_use_global_queue = undef,
$passenger_app_env = undef,
$mod_package = undef,
$mod_package_ensure = undef,
$mod_lib = undef,
Expand Down Expand Up @@ -73,6 +74,7 @@
# - $passenger_max_requests
# - $passenger_stat_throttle_rate
# - $passenger_use_global_queue
# - $passenger_app_env
# - $rack_autodetect
# - $rails_autodetect
file { 'passenger.conf':
Expand Down
6 changes: 4 additions & 2 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
$allow_encoded_slashes = undef,
$suexec_user_group = undef,
$passenger_app_root = undef,
$passenger_app_env = undef,
$passenger_ruby = undef,
$passenger_min_instances = undef,
$passenger_start_timeout = undef,
Expand Down Expand Up @@ -225,7 +226,7 @@
include ::apache::mod::suexec
}

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

Expand Down Expand Up @@ -839,11 +840,12 @@

# Template uses:
# - $passenger_app_root
# - $passenger_app_env
# - $passenger_ruby
# - $passenger_min_instances
# - $passenger_start_timeout
# - $passenger_pre_start
if $passenger_app_root or $passenger_ruby or $passenger_min_instances or $passenger_start_timeout or $passenger_pre_start {
if $passenger_app_root or $passenger_app_env or $passenger_ruby or $passenger_min_instances or $passenger_start_timeout or $passenger_pre_start {
concat::fragment { "${name}-passenger":
target => "${priority_real}${filename}.conf",
order => 300,
Expand Down
6 changes: 6 additions & 0 deletions spec/classes/mod/passenger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@
end
it { is_expected.to contain_file('passenger.conf').with_content(/^ PassengerUseGlobalQueue on$/) }
end
describe "with passenger_app_env => 'foo'" do
let :params do
{ :passenger_app_env => 'foo' }
end
it { is_expected.to contain_file('passenger.conf').with_content(/^ PassengerAppEnv foo$/) }
end
describe "with mod_path => '/usr/lib/foo/mod_foo.so'" do
let :params do
{ :mod_path => '/usr/lib/foo/mod_foo.so' }
Expand Down
1 change: 1 addition & 0 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
'suexec_user_group' => 'root root',
'allow_encoded_slashes' => 'nodecode',
'passenger_app_root' => '/usr/share/myapp',
'passenger_app_env' => 'test',
'passenger_ruby' => '/usr/bin/ruby1.9.1',
'passenger_min_instances' => '1',
'passenger_start_timeout' => '600',
Expand Down
3 changes: 3 additions & 0 deletions templates/mod/passenger.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@
<%- if @passenger_use_global_queue -%>
PassengerUseGlobalQueue <%= @passenger_use_global_queue %>
<%- end -%>
<%- if @passenger_app_env -%>
PassengerAppEnv <%= @passenger_app_env %>
<%- end -%>
</IfModule>
3 changes: 3 additions & 0 deletions templates/vhost/_passenger.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<% if @passenger_app_root -%>
PassengerAppRoot <%= @passenger_app_root %>
<% end -%>
<% if @passenger_app_env -%>
PassengerAppEnv <%= @passenger_app_env %>
<% end -%>
<% if @passenger_ruby -%>
PassengerRuby <%= @passenger_ruby %>
<% end -%>
Expand Down

0 comments on commit 016c0c7

Please sign in to comment.