diff options
author | Sam Stephenson <sam@37signals.com> | 2005-11-30 19:18:55 +0000 |
---|---|---|
committer | Sam Stephenson <sam@37signals.com> | 2005-11-30 19:18:55 +0000 |
commit | 833d9c89fcc6125545bf16339ebf038a7889e036 (patch) | |
tree | bff6d8e6f241e0a525a111420f95eba4f0ec6200 /railties/lib | |
parent | 191dfe8c6df0f72b5a9abaea0f754177f48859dc (diff) | |
download | rails-833d9c89fcc6125545bf16339ebf038a7889e036.tar.gz rails-833d9c89fcc6125545bf16339ebf038a7889e036.tar.bz2 rails-833d9c89fcc6125545bf16339ebf038a7889e036.zip |
Run initialize_logger in script/lighttpd to ensure the log file exists before tailing it
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3198 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/commands/servers/lighttpd.rb | 11 | ||||
-rw-r--r-- | railties/lib/initializer.rb | 4 |
2 files changed, 9 insertions, 6 deletions
diff --git a/railties/lib/commands/servers/lighttpd.rb b/railties/lib/commands/servers/lighttpd.rb index 16baf1e367..8f67721a04 100644 --- a/railties/lib/commands/servers/lighttpd.rb +++ b/railties/lib/commands/servers/lighttpd.rb @@ -8,6 +8,8 @@ unless defined?(FCGI) exit 1 end +require 'initializer' +configuration = Rails::Initializer.run(:initialize_logger).configuration config_file = "#{RAILS_ROOT}/config/lighttpd.conf" @@ -21,8 +23,8 @@ end 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 @@ else 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 diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 6287f0ddc1..d1fe8908bc 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -38,7 +38,9 @@ module Rails # 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 |