I've installed thin on my machine, but I want it to start up instead of Webrick when I type
script/server
at the console
Any idea where to find it?
I know this can be done, because once I install mongrel script/server invokes it instead of Webrick
| SitePoint Sponsor |



I've installed thin on my machine, but I want it to start up instead of Webrick when I type
script/server
at the console
Any idea where to find it?
I know this can be done, because once I install mongrel script/server invokes it instead of Webrick
I didn't know, but I hunted it down. script/server basically just requires "commands/server" so I hunted that down: rails/railties/lib/commands/server.rb (which I have in vendor/ because I froze Rails; otherwise it's in your gem directory).
That file just fumbles around, blindly requiring the fcgi and mongrel libraries. Then it checks command-line arguments, but if none were given, just uses the first of mongrel, lighttpd, and webrick which seem to be installed. Then it just requires the file in the servers/ subdirectory corresponding to the server that should load.
It looks like you could just make a rails/railties/lib/commands/servers/thin.rb with a single line `thin start` (or be fancier if you want). Then you could run "script/server thin". If you fiddled with the server.rb you could make it the default, but I don't know of a way to do that which wouldn't be overridden the next time you update Rails.
There are some things you shouldn't try to code at home.



I had just been screwing around with those files before you wrote.
Depending on the version of rails you're running the file resides in
C:\ruby\lib\ruby\gems\1.8\gems\rails-2.0.2\lib\commands
I've edited it so it calls a thin.rb
located in
C:\ruby\lib\ruby\gems\1.8\gems\rails-2.0.2\lib\commands\servers
but it doesn't work
All I have in there is
system("thin start")
What was your edit? Did you modify the line in server.rb that says
Code Ruby:when "lighttpd", "mongrel", "webrick"
to include "thin"? Or something else?
There are some things you shouldn't try to code at home.



yes I did ... in fact here is my modified server.rb
Code: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 # Mongrel not available end server = case ARGV.first when "lighttpd", "mongrel", "webrick", "thin" ARGV.shift else if defined?(Mongrel) "mongrel" elsif defined?(Thin) "thin" elsif RUBY_PLATFORM !~ /(:?mswin|mingw)/ && !silence_stderr { `lighttpd -version` }.blank? && defined?(FCGI) "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 "thin" puts "=> Booting Thin (use 'script/server webrick' to force WEBrick)" when "mongrel" puts "=> Booting Mongrel (use 'script/server webrick' to force WEBrick)" end %w(cache pids sessions sockets).each { |dir_to_make| FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', dir_to_make)) } require "commands/servers/#{server}"
And you're sure it's the server.rb that's getting used? I tried the same mod and it worked. Check that ./script/about shows the Rails version you expect; check that there's no Rails frozen in vendor.
There are some things you shouldn't try to code at home.
Bookmarks