mirror of
https://github.com/github/rails.git
synced 2026-04-04 03:00:58 -04:00
Mongrel: script/server tails the rails log like it does with lighttpd. Closes #5541.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4506 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Mongrel: script/server tails the rails log like it does with lighttpd. #5541 [mike@clarkware.com]
|
||||
|
||||
* Don't assume Active Record is available. #5497 [bob@sporkmonger.com]
|
||||
|
||||
* Mongrel: script/server works on Win32. #5499 [jeremydurham@gmail.com]
|
||||
|
||||
19
railties/lib/commands/servers/base.rb
Normal file
19
railties/lib/commands/servers/base.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
def tail(log_file)
|
||||
cursor = File.size(log_file)
|
||||
last_checked = Time.now
|
||||
tail_thread = Thread.new do
|
||||
File.open(log_file, 'r') do |f|
|
||||
loop do
|
||||
f.seek cursor
|
||||
if f.mtime > last_checked
|
||||
last_checked = f.mtime
|
||||
contents = f.read
|
||||
cursor += contents.length
|
||||
print contents
|
||||
end
|
||||
sleep 1
|
||||
end
|
||||
end
|
||||
end
|
||||
tail_thread
|
||||
end
|
||||
@@ -1,4 +1,5 @@
|
||||
require 'rbconfig'
|
||||
require 'commands/servers/base'
|
||||
|
||||
unless RUBY_PLATFORM !~ /mswin/ && !silence_stderr { `lighttpd -version` }.blank?
|
||||
puts "PROBLEM: Lighttpd is not available on your system (or not in your path)"
|
||||
@@ -52,23 +53,7 @@ if !detach
|
||||
puts "=> Call with -d to detach"
|
||||
puts "=> Ctrl-C to shutdown server (see config/lighttpd.conf for options)"
|
||||
detach = false
|
||||
|
||||
cursor = File.size(configuration.log_path)
|
||||
last_checked = Time.now
|
||||
tail_thread = Thread.new do
|
||||
File.open(configuration.log_path, 'r') do |f|
|
||||
loop do
|
||||
f.seek cursor
|
||||
if f.mtime > last_checked
|
||||
last_checked = f.mtime
|
||||
contents = f.read
|
||||
cursor += contents.length
|
||||
print contents
|
||||
end
|
||||
sleep 1
|
||||
end
|
||||
end
|
||||
end
|
||||
tail_thread = tail(configuration.log_path)
|
||||
end
|
||||
|
||||
trap(:INT) { exit }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
require 'rbconfig'
|
||||
require 'commands/servers/base'
|
||||
|
||||
unless defined?(Mongrel)
|
||||
puts "PROBLEM: Mongrel is not available on your system (or not in your path)"
|
||||
@@ -26,16 +27,19 @@ end
|
||||
default_port, default_ip = 3000, '0.0.0.0'
|
||||
puts "=> Rails application started on http://#{ip || default_ip}:#{port || default_port}"
|
||||
|
||||
log_file = Pathname.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log").cleanpath
|
||||
|
||||
tail_thread = nil
|
||||
|
||||
if !detach
|
||||
puts "=> Call with -d to detach"
|
||||
puts "=> Ctrl-C to shutdown server"
|
||||
detach = false
|
||||
tail_thread = tail(log_file)
|
||||
end
|
||||
|
||||
trap(:INT) { exit }
|
||||
|
||||
tail_thread = nil
|
||||
|
||||
begin
|
||||
ARGV.unshift("start")
|
||||
load 'mongrel_rails'
|
||||
|
||||
Reference in New Issue
Block a user