aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/commands/servers/thin.rb
blob: 833469cab19427043497bd5d41578b4240a01b0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'rbconfig'
require 'commands/servers/base'
require 'thin'


options = ARGV.clone
options.insert(0,'start') unless Thin::Runner.commands.include?(options[0])

thin = Thin::Runner.new(options)

puts "=> Rails #{Rails.version} application starting on http://#{thin.options[:address]}:#{thin.options[:port]}"
puts "=> Ctrl-C to shutdown server"

log = Pathname.new("#{File.expand_path(RAILS_ROOT)}/log/#{RAILS_ENV}.log").cleanpath
open(log, (File::WRONLY | File::APPEND | File::CREAT)) unless File.exist? log
tail_thread = tail(log)
trap(:INT) { exit }

begin
  thin.run!
ensure
  tail_thread.kill if tail_thread
  puts 'Exiting'
end