Functional tests now work properly, bearing in mind whether a user is logged in or...
[depot.git] / vendor / rails / railties / lib / commands / server.rb
1 require 'active_support'
2 require 'fileutils'
3
4 begin
5 require_library_or_gem 'fcgi'
6 rescue Exception
7 # FCGI not available
8 end
9
10 begin
11 require_library_or_gem 'mongrel'
12 rescue Exception
13 # Mongrel not available
14 end
15
16 begin
17 require_library_or_gem 'thin'
18 rescue Exception
19 # Thin not available
20 end
21
22 server = case ARGV.first
23 when "lighttpd", "mongrel", "new_mongrel", "webrick", "thin"
24 ARGV.shift
25 else
26 if defined?(Mongrel)
27 "mongrel"
28 elsif defined?(Thin)
29 "thin"
30 elsif RUBY_PLATFORM !~ /(:?mswin|mingw)/ && !silence_stderr { `lighttpd -version` }.blank? && defined?(FCGI)
31 "lighttpd"
32 else
33 "webrick"
34 end
35 end
36
37 case server
38 when "webrick"
39 puts "=> Booting WEBrick..."
40 when "lighttpd"
41 puts "=> Booting lighttpd (use 'script/server webrick' to force WEBrick)"
42 when "mongrel", "new_mongrel"
43 puts "=> Booting Mongrel (use 'script/server webrick' to force WEBrick)"
44 when "thin"
45 puts "=> Booting Thin (use 'script/server webrick' to force WEBrick)"
46 end
47
48 %w(cache pids sessions sockets).each { |dir_to_make| FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', dir_to_make)) }
49 require "commands/servers/#{server}"