lib/rconf/configurators/passenger_configurator.rb in rconf-0.8.3 vs lib/rconf/configurators/passenger_configurator.rb in rconf-0.8.4
- old
+ new
@@ -13,11 +13,11 @@
module RightConf
class PassengerConfigurator
- PASSENGER_GEM_VERSION = '2.2.15'
+ PASSENGER_GEM_VERSION = '3.0.2'
DEFAULT_NGINX_INSTALL = ['/opt/nginx', File.join(ENV['HOME'], 'nginx')]
include Configurator
@@ -31,26 +31,48 @@
settings :library_src_path => "Path to library sources, #{File.expand_path(File.join(Dir.getwd, '..', 'library'))} by default",
:gem_version => "Passenger gem version #{PASSENGER_GEM_VERSION} by default",
:install_path => 'Path to nginx installation directory, uses /opt/nginx if it ' +
'is writable by the current user or ~/nginx otherwise by default'
- # Install passenger gem in given ruby then run nginx install script
+ # Check that passenger gem is installed and that passenger+nginx is installed
#
# === Return
- # true:: Always return true
- def run_linux
+ # true:: If both are installed
+ # false:: Otherwise
+ def check_linux
set_defaults
report_check("Checking for passenger gem #{gem_version}")
res = Command.execute_in_ruby('gem', 'list', 'passenger')
success = (res.output =~ /^passenger \(#{gem_version}\)$/)
report_result(success)
- install_gem unless success
- report_check('Checking for passenger+nginx')
- res = Command.execute('which', 'nginx').success?
- res = File.exists?(File.join(install_path, 'sbin', 'nginx')) unless res
- report_result(res)
- install_passenger unless res
+ if success
+ report_check('Checking for passenger+nginx')
+ res = Command.execute('which', 'nginx').success?
+ res = File.exists?(File.join(install_path, 'sbin', 'nginx')) unless res
+ report_result(res)
+ success = res
+ end
+ success
+ end
+ alias :check_darwin :check_linux
+
+ # Not implemented on Windows
+ #
+ # === Raise
+ # (Exception):: Always raise
+ def check_windows
+ raise "Passenger is not supported on Windows!"
+ end
+
+ # Install passenger gem in given ruby then run nginx install script
+ #
+ # === Return
+ # true:: Always return true
+ def run_linux
+ set_defaults
+ install_gem
+ install_passenger
true
end
alias :run_darwin :run_linux
# Not implemented on windows
@@ -173,10 +195,10 @@
#
# === Return
# config(String):: Nginx config
def nginx_config
ruby_bin = Command.execute_in_ruby('which', 'ruby').output.chomp
- res = Command.execute_in_ruby('ruby', '-e', "require 'rubygems';puts Gem.source_index.find_name('passenger').detect { |g| g.version.to_s == '#{PASSENGER_GEM_VERSION}' }.full_gem_path",
+ res = Command.execute_in_ruby('ruby', '-e', "require 'rubygems';puts Gem.source_index.find_name('passenger').detect { |g| g.version.to_s == '#{gem_version}' }.full_gem_path",
:abort_on_failure => 'Could not find passenger gem to build passenger_root')
passenger_root = res.output.chomp
report_fatal('Could not find passenger gem') if passenger_root.empty?
<<-EOS
worker_processes 1;