Skip to content

Loading…

Adds Passenger Enterprise support and resolv.conf management. #141

Merged
merged 2 commits into from

3 participants

Commits on Nov 21, 2012
  1. @kplawver
Commits on Nov 28, 2012
  1. @technicalpickles

    Add note about setting :enteprise: true, and add error for when that'…

    technicalpickles committed with Rails Machine
    …s not specified
This page is out of date. Refresh to see the latest.
View
12 Readme.rdoc
@@ -42,3 +42,15 @@ It's easy enough:
You can find more examples in the documentation[http://railsmachine.github.com/moonshine] and on the Wiki[https://github.com/railsmachine/moonshine/wiki].
For help or general discussion, visit the Moonshine newsgroup[http://groups.google.com/group/railsmachine-moonshine].
+
+== Passenger Enterprise Support
+
+We've added support for Passenger Enterprise Edition! In order to install it, you need to make a few changes to moonshine.yml. Since you have to download the gem from Phusion, you now need to tell us where it is. You also need to put your license file in app/manifests/templates and call it <code>passenger-enterprise-license</code> so we can put it in the right place during install.
+
+This is what a passenger enterprise block in moonshine.yml should look like (in addition to your usual Passenger settings):
+
+<pre><code>:passenger:
+ :version: 3.0.18
+ :enterprise: true
+ :gemfile: vendor/gems/passenger-enterprise-server-3.0.18.gem
+ :rolling_restarts: true</code></pre>
View
17 lib/moonshine/manifest/rails/os.rb
@@ -217,6 +217,23 @@ def exec(*args)
super(name, hash)
end
end
+
+ #### Resolv.conf
+
+ # This allows you to manage /etc/resolv.conf, adding, removing and re-ordering nameservers.
+
+ def resolv_conf
+ configure(:resolv => {})
+ if configuration[:resolv][:nameservers].nil? || configuration[:resolv][:nameservers].empty?
+ configuration[:resolv][:nameservers] = ['8.8.4.4','8.8.8.8','208.67.222.222','208.67.220.220']
+ end
+
+ file '/etc/resolv.conf',
+ :ensure => :present,
+ :mode => '744',
+ :owner => 'root',
+ :content => template(File.join(File.dirname(__FILE__), 'templates', 'resolv.conf.erb'))
+ end
private
View
29 lib/moonshine/manifest/rails/passenger.rb
@@ -1,11 +1,29 @@
module Moonshine::Manifest::Rails::Passenger
- BLESSED_VERSION = '3.0.11'
+ BLESSED_VERSION = '3.0.17'
# Install the passenger gem
def passenger_gem
configure(:passenger => {})
- if configuration[:passenger][:version] && configuration[:passenger][:version] < "3.0"
+ package 'libcurl4-openssl-dev', :ensure => :installed
+
+ if configuration[:passenger][:enterprise]
+ package "passenger",
+ :provider => :gem,
+ :ensure => :absent
+
+ raise "Passenger Enterprise enabled, but no gemfile specified. Update config/moonshine.yml with :gemfile for :passenger and try again" unless configuration[:passenger][:gemfile]
+
+ exec 'install passenger-enterprise-server gem',
+ :command => "gem install #{configuration[:passenger][:gemfile]}",
+ :unless => "gem list | grep passenger-enterprise-server | grep #{configuration[:passenger][:version]}",
+ :cwd => rails_root,
+ :require => [ package('libcurl4-openssl-dev'), package('passenger')]
+
+ file '/etc/passenger-enterprise-license',
+ :ensure => :present,
+ :content => template(File.join(File.dirname(__FILE__), 'templates', 'passenger-enterprise-license'))
+ elsif configuration[:passenger][:version] && configuration[:passenger][:version] < "3.0"
package "passenger",
:ensure => configuration[:passenger][:version],
:provider => :gem
@@ -14,13 +32,11 @@ def passenger_gem
:ensure => BLESSED_VERSION,
:provider => :gem,
:require => [ package('libcurl4-openssl-dev') ]
- package 'libcurl4-openssl-dev', :ensure => :installed
elsif configuration[:passenger][:version]
package "passenger",
:ensure => (configuration[:passenger][:version]),
:provider => :gem,
:require => [ package('libcurl4-openssl-dev') ]
- package 'libcurl4-openssl-dev', :ensure => :installed
end
end
@@ -94,7 +110,10 @@ def passenger_site
def passenger_configure_gem_path
configure(:passenger => {})
- if configuration[:passenger][:version].nil? || configuration[:passenger][:version] == :latest
+ if configuration[:passenger][:enterprise]
+ raise "You must define a version for passenger enterprise in moonshine.yml" if configuration[:passenger][:version].blank?
+ configure(:passenger => {:path => "#{Gem.dir}/gems/passenger-enterprise-server-#{configuration[:passenger][:version]}"})
+ elsif configuration[:passenger][:version].nil? || configuration[:passenger][:version] == :latest
configure(:passenger => { :path => "#{Gem.dir}/gems/passenger-#{BLESSED_VERSION}" })
elsif configuration[:passenger][:version]
configure(:passenger => { :path => "#{Gem.dir}/gems/passenger-#{configuration[:passenger][:version]}" })
View
47 lib/moonshine/manifest/rails/templates/passenger.conf.erb
@@ -174,3 +174,50 @@ PassengerStatThrottleRate <%= configuration[:passenger][:stat_throttle_rate] ||
<% if supports_passenger_buffer_response? %>
PassengerBufferResponse <%= passenger_config_boolean(configuration[:passenger][:buffer_response], true)%>
<% end %>
+
+## PassengerFriendlyErrorPages
+# Phusion Passenger can display friendly error pages whenever an application fails to start.
+# This friendly error page presents the startup error message, some suggestions for solving the problem, and a backtrace.
+# This feature is very useful during application development and useful for less experienced system administrators,
+# but the page might reveal potentially sensitive information, depending on the application.
+# Experienced system administrators who are using Phusion Passenger on serious production servers should consider turning this feature off.
+
+PassengerFriendlyErrorPages <%= passenger_config_boolean(configuration[:passenger][:friendly_error_pages], false) %>
+
+<% if configuration[:passenger][:enterprise] %>
+
+## PassengerMaxRequestTime
+# The maximum amount of time, in seconds, that an application process may take to process a request.
+# If the request takes longer than this amount of time, then the application process will be forcefully shut down, and possibly restarted upon the next request.
+# A value of 0 means that there is no time limit.
+
+PassengerMaxRequestTime <%= configuration[:passenger][:max_request_time] || '0' %>
+
+## PassengerMemoryLimit
+# The maximum amount of memory that an application process may use, in megabytes.
+# Once an application process has surpassed its memory limit, it will process all the requests currently present in its queue and then shut down.
+# A value of 0 means that there is no maximum: the application’s memory usage will not be checked.
+
+PassengerMemoryLimit <%= configuration[:passenger][:memory_limit] || '0' %>
+
+##
+
+## PassengerRollingRestarts
+#
+# Enables or disables support for rolling restarts. Normally when you restart an application (by touching restart.txt), Phusion Passenger would shut down all application processes and spawn a new one. The spawning of a new application process could take a while, and any requests that come in during this time will be blocked until this first application process has spawned.
+
+PassengerRollingRestarts <%= passenger_config_boolean(configuration[:passenger][:rolling_restarts], false) %>
+
+## PassengerResistDeploymentErrors
+
+PassengerResistDeploymentErrors <%= passenger_config_boolean(configuration[:passenger][:resist_deployment_errors], false) %>
+
+<% if configuration[:passenger][:debug_log_file] %>
+## PassengerDebugLogFile
+# By default, passenger debug and error messages go to the webserver log file.
+# If you want them to go somewhere else, this is the place.
+
+PassengerDebugLogFile <%= configuration[:passenger][:debug_log_file] %>
+<% end %>
+
+<% end %>
View
6 lib/moonshine/manifest/rails/templates/resolv.conf.erb
@@ -0,0 +1,6 @@
+# Generated by Moonshine.
+# Any edits you make will be wiped out on the next deploy.
+
+<% configuration[:resolv][:nameservers].each do |nameserver| %>
+nameserver <%= nameserver %>
+<% end %>
Something went wrong with that request. Please try again.