diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-08-05 22:11:24 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-08-05 22:11:24 +0000 |
commit | 900afae41b00b27c6f1fc53044fe4ca917f09c81 (patch) | |
tree | 8b81ca9522e725e97c8f886b4fa5d47124977fe5 /railties | |
parent | 4699c336f7fda526373218235c5067583b89c1c6 (diff) | |
download | rails-900afae41b00b27c6f1fc53044fe4ca917f09c81.tar.gz rails-900afae41b00b27c6f1fc53044fe4ca917f09c81.tar.bz2 rails-900afae41b00b27c6f1fc53044fe4ca917f09c81.zip |
Added that you can change the web server port in config/lighttpd.conf from script/server --port/-p (closes #5465) [mats@imediatec.co.uk]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4676 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/lib/commands/servers/lighttpd.rb | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 4b4d015fb2..098e4b317a 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added that you can change the web server port in config/lighttpd.conf from script/server --port/-p #5465 [mats@imediatec.co.uk] + * script/performance/profiler compatibility with the new ruby-prof, including an option to choose the results printer. #5679 [shugo@ruby-lang.org] * Fixed the failsafe response so it uses either the current recognized controller or ApplicationController. [Rick Olson] diff --git a/railties/lib/commands/servers/lighttpd.rb b/railties/lib/commands/servers/lighttpd.rb index 1d5ca55f61..8908aec616 100644 --- a/railties/lib/commands/servers/lighttpd.rb +++ b/railties/lib/commands/servers/lighttpd.rb @@ -18,8 +18,10 @@ default_config_file = config_file = Pathname.new("#{RAILS_ROOT}/config/lighttpd. require 'optparse' detach = false +user_defined_active_port = nil ARGV.options do |opt| + opt.on("-p", "--port=port", "Changes the server.port number in the config/lighttpd.conf") { |port| command_line_port = port } opt.on('-c', "--config=#{config_file}", 'Specify a different lighttpd config file.') { |path| config_file = path } opt.on('-h', '--help', 'Show this message.') { puts opt; exit 0 } opt.on('-d', '-d', 'Call with -d to detach') { detach = true; puts "=> Configuration in config/lighttpd.conf" } @@ -41,6 +43,21 @@ unless File.exist?(config_file) FileUtils.cp(source, config_file) end +# open the config/lighttpd.conf file and add the current user defined port setting to it +if command_line_port + File.open(config_file, 'r+') do |config| + lines = config.readlines + + lines.each do |line| + line.gsub!(/^\s*server.port\s*=\s*(\d+)/, "server.port = #{command_line_port}") + end + + config.rewind + config.print(lines) + config.truncate(config.pos) + end +end + config = IO.read(config_file) default_port, default_ip = 3000, '0.0.0.0' port = config.scan(/^\s*server.port\s*=\s*(\d+)/).first rescue default_port |