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

Allow apache::mod::passenger::passenger_pre_start to accept multiple URIs #1776

Merged
merged 2 commits into from
Mar 29, 2018

Conversation

smortex
Copy link
Collaborator

@smortex smortex commented Mar 28, 2018

These commits improve usage of passenger_pre_start by:

  • Outputting PassengerPreStart outside the <VirtualHost> block (using this directive inside is not supported and produce a warning with (at least) passenger-5.2.1);
  • Allowing to set multiple URIs (to start multiple applications served within a single VirutalHost).

Only the generated configuration is affected, existing puppet code does not need to be modified for the fix to take effect (passenger_pre_start is still a parameter of apache::vhost).

This fix this passenger warning:
WARNING: PassengerPreStart cannot occur within <VirtualHost> section

https://www.phusionpassenger.com/library/config/apache/reference/#passengerprestart
A single VirtualHost may serve more than one application (using
PassengerBaseURI [1]).  In such a situation, it makes sense to preload
each application by using multiple PassengerPreStart [2]

1. https://www.phusionpassenger.com/library/config/apache/reference/#passengerbaseuri
2. https://www.phusionpassenger.com/library/config/apache/reference/#passengerprestart
@@ -125,7 +125,9 @@
PassengerPoolIdleTime <%= @passenger_pool_idle_time %>
<%- end -%>
<%- if @passenger_pre_start -%>
PassengerPreStart <%= @passenger_pre_start %>
<%- [@passenger_pre_start].flatten.compact.each do |passenger_pre_start| -%>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One alternative approach to ensuring array values than the usual [var].flatten is to use Array(var). It also has a benefit when var could be nil:

[1] pry(main)> [nil].flatten
=> [nil]
[2] pry(main)> [[]].flatten
=> []
[3] pry(main)> Array(nil)
=> []
[4] pry(main)> Array([])
=> []

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though it often has undesirable behavior when var could be a hash:

[1] pry(main)> [{}].flatten
=> [{}]
[2] pry(main)> [{:foo => :bar}].flatten
=> [{:foo=>:bar}]
[3] pry(main)> Array({})
=> []
[4] pry(main)> Array({:foo => :bar})
=> [[:foo, :bar]]

@hunner hunner added the feature label Mar 29, 2018
@hunner hunner changed the title Rework PassengerPreStart Allow apache::mod::passenger::passenger_pre_start to accept multiple URIs Mar 29, 2018
@hunner hunner merged commit ca2d7d5 into puppetlabs:master Mar 29, 2018
hunner added a commit that referenced this pull request Mar 29, 2018
Allow `apache::mod::passenger::passenger_pre_start` to accept multiple URIs
@smortex smortex deleted the rework-PassengerPreStart branch February 6, 2019 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants