aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/commands/servers/lighttpd.rb17
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