Permalink
Browse files

Run initialize_logger in script/lighttpd to ensure the log file exist…

…s before tailing it

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3198 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 191dfe8 commit 833d9c89fcc6125545bf16339ebf038a7889e036 @sstephenson sstephenson committed Nov 30, 2005
Showing with 11 additions and 6 deletions.
  1. +2 −0 railties/CHANGELOG
  2. +6 −5 railties/lib/commands/servers/lighttpd.rb
  3. +3 −1 railties/lib/initializer.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Run initialize_logger in script/lighttpd to ensure the log file exists before tailing it. [Sam Stephenson]
+
* Make load_fixtures include csv fixtures. #3053. [me@mdaines.com]
* Fix freeze_gems so that the latest rails version is dumped by default. [Nicholas Seckar]
@@ -8,6 +8,8 @@
exit 1
end
+require 'initializer'
+configuration = Rails::Initializer.run(:initialize_logger).configuration
config_file = "#{RAILS_ROOT}/config/lighttpd.conf"
@@ -21,8 +23,8 @@
config = IO.read(config_file)
default_port, default_ip = 3000, '0.0.0.0'
-port = config.scan(/^server.port\s*=\s*(\d+)/).first rescue default_port
-ip = config.scan(/^server.bind\s*=\s*"([^"]+)"/).first rescue default_ip
+port = config.scan(/^\s*server.port\s*=\s*(\d+)/).first rescue default_port
+ip = config.scan(/^\s*server.bind\s*=\s*"([^"]+)"/).first rescue default_ip
puts "=> Rails application started on http://#{ip || default_ip}:#{port || default_port}"
tail_thread = nil
@@ -35,11 +37,10 @@
puts "=> Ctrl-C to shutdown server (see config/lighttpd.conf for options)"
detach = false
- log_path = "#{RAILS_ROOT}/log/#{RAILS_ENV}.log"
- cursor = File.size(log_path)
+ cursor = File.size(configuration.log_path)
last_checked = Time.now
tail_thread = Thread.new do
- File.open(log_path, 'r') do |f|
+ File.open(configuration.log_path, 'r') do |f|
loop do
f.seek cursor
if f.mtime > last_checked
@@ -38,7 +38,9 @@ class Initializer
# incuring the overhead of completely loading the entire environment.
def self.run(command = :process, configuration = Configuration.new)
yield configuration if block_given?
- new(configuration).send(command)
+ initializer = new configuration
+ initializer.send(command)
+ initializer
end
# Create a new Initializer instance that references the given Configuration

0 comments on commit 833d9c8

Please sign in to comment.