instiki/vendor/rails/railties/lib/commands/server.rb

50 lines
1.1 KiB
Ruby
Raw Normal View History

2007-01-22 14:43:50 +01:00
require 'active_support'
require 'fileutils'
begin
require_library_or_gem 'fcgi'
rescue Exception
# FCGI not available
end
begin
require_library_or_gem 'mongrel'
rescue Exception
# Mongrel not available
end
begin
require_library_or_gem 'thin'
rescue Exception
# Thin not available
end
2007-01-22 14:43:50 +01:00
server = case ARGV.first
when "lighttpd", "mongrel", "new_mongrel", "webrick", "thin"
2007-01-22 14:43:50 +01:00
ARGV.shift
else
if defined?(Mongrel)
"mongrel"
elsif defined?(Thin)
"thin"
elsif RUBY_PLATFORM !~ /(:?mswin|mingw)/ && !silence_stderr { `lighttpd -version` }.blank? && defined?(FCGI)
2007-01-22 14:43:50 +01:00
"lighttpd"
else
"webrick"
end
end
case server
when "webrick"
puts "=> Booting WEBrick..."
when "lighttpd"
puts "=> Booting lighttpd (use 'script/server webrick' to force WEBrick)"
when "mongrel", "new_mongrel"
puts "=> Booting Mongrel (use 'script/server webrick' to force WEBrick)"
when "thin"
puts "=> Booting Thin (use 'script/server webrick' to force WEBrick)"
2007-01-22 14:43:50 +01:00
end
%w(cache pids sessions sockets).each { |dir_to_make| FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', dir_to_make)) }
2007-01-22 14:43:50 +01:00
require "commands/servers/#{server}"