Permalink
Browse files

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
  • Loading branch information...
dhh committed Aug 5, 2006
1 parent 4699c33 commit 900afae41b00b27c6f1fc53044fe4ca917f09c81
Showing with 19 additions and 0 deletions.
  1. +2 −0 railties/CHANGELOG
  2. +17 −0 railties/lib/commands/servers/lighttpd.rb
View
@@ -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]
@@ -18,8 +18,10 @@
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 @@
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

0 comments on commit 900afae

Please sign in to comment.