Permalink
Browse files

Added support to import 'server_internal_config.yml' file.

  • Loading branch information...
1 parent 9c67109 commit 45f10fbe78e740daf592db351c40150cce84a75a Nikunj Limbaseeya committed Jul 8, 2011
Showing with 91 additions and 9 deletions.
  1. +42 −0 conf/server_internal_config.example.yml
  2. +25 −8 lib/installer.rb
  3. +1 −1 lib/webroar_command.rb
  4. +22 −0 lib/whelper.rb
  5. +1 −0 tasks/gem.rake
@@ -0,0 +1,42 @@
+# Server’s Internal Configuration
+
+starling:
+ host: 127.0.0.1 # Host that runs the starling message queue
+ port: 22122 # Port number of the starling message queue
+ profiler_queue_name: profiler_queue # Queue to read/write profiling data
+ exception_queue_name: exception_queue # Queue to read/write exceptions
+ pid_queue_name: pid_queue # Queue to dispatch worker process id
+ max_queue_items: 30000 # Maximum number of unprocessed messages in queue. One message is approximately 1 Kb
+
+webroar:
+ analyzer: on # Flag to set server analytics on/off
+ admin_panel: on # Flag to start Admin Panel with server
+
+webroar_analyzer_script:
+ pid_file: /var/run/webroar_analyzer.pid # File to store pid of analyzer
+ daemonize: true # true or false
+ log_file: /var/log/webroar/analyzer.log # Log file
+ sampling_rate: 1 # Sampling time (in mins)
+ environment: production # to choose the database specific to environment
+
+## Application Configuration ##
+Application:
+ message_queue_size: 2048 # Queue size of pending requests for each application. Default value is 2048
+ maximum_request_ratio: 1 # Ratio of pending requests to active workes to create new worker. Default value is 1
+ minimum_request_ratio: 3 # Ratio of pending requests to active workes to destroy free worker. Default value is 3
+ high_load_time: 2 # Number of seconds to check high load before creating new worker. Default value is 2
+ low_load_time: 600 # Number of seconds to check low load before destroying free worker. Default value is 600
+ maximum_hosts: 16 # Maximum number of hosts allowed. Default value is 16
+
+## Worker Configuration ##
+Worker:
+ maximum_request_body_size: 65536 # If the request body is larger than this size, use file to read/write request body. Default value is 65536
+ maximum_workers: 20 # Maximum number of workers allowed. Default value is 20
+ pending_workers: 10 # Maximum number of pending workers. Default value is 10
+ add_trials: 3 # Number of consecutive tries to add worker. Default value is 3
+ add_wait: 1800 # Number of seconds to wait for creating new worker, if all consecutive trials are failed. Default value is 1800
+ add_timeout: 25 # Number of seconds to wait for a response form newly created worker. Default value is 25. Set value to 0 to disable add timeout.
+ kill_timeout: 10 # Number of seconds to wait before killing identified stuck worker. Default value is 10
+ idle_time: 60 # If worker is unable to process request within this time, sends PING signal. Default value is 60. Set value to 0 to disable idle timer.
+ ping_timeout: 15 # Number of seconds to wait for a response of PING signal. Default value is 15
+ ping_trials: 2 # Number of PING signals to identify stuck worker. Default value is 2
View
@@ -17,7 +17,6 @@
# along with WebROaR. If not, see <http://www.gnu.org/licenses/>.
#
-require "fileutils"
require 'user_interaction'
module Webroar
@@ -393,8 +392,7 @@ def log_rotate_darwin(add)
# Close the archive file
saved.close
-
- FileUtils.mv("tmp.conf", "/etc/newsyslog.conf")
+ Webroar::FileHelper.move("tmp.conf", "/etc/newsyslog.conf")
end
# Add/Remove log rotate script
@@ -416,6 +414,11 @@ def write_server_port
s['SSL Specification'] = {'ssl_port' => 443, 'ssl_support' => "disabled", 'certificate_file' => nil, 'key_file' => nil} if @ssl
info = {'Server Specification' => s}
write_server_config_file(info)
+
+ # move *.example.yml files to *.yml files in 'conf' folder
+ file = File.join(WEBROAR_ROOT, "conf", "server_internal_config.example.yml")
+ Webroar::FileHelper.move(file, file.gsub(/\.example\.yml$/, '.yml'))
+ Webroar::FileHelper.remove(File.join(WEBROAR_ROOT, "conf", "mail_config.yml"))
end
def write_server_config_file(info)
@@ -669,13 +672,27 @@ def import_files(gem_name)
puts "done."
return YAML.load(File.open(WEBROAR_CONFIG_FILE))["Server Specification"]["port"]
end
-
- FileUtils.copy(File.join(import_dir,"src","admin_panel","config","user.yml"), ADMIN_USER_FILE)
- FileUtils.copy(File.join(import_dir,"src","admin_panel","config","database.yml"), DB_CONFIG_FILE)
+
+ # Copy all *.yml files from older version.
+ Webroar::FileHelper.copy(File.join(import_dir,"src","admin_panel","config","user.yml"), ADMIN_USER_FILE)
+ Webroar::FileHelper.copy(File.join(import_dir,"src","admin_panel","config","database.yml"), DB_CONFIG_FILE)
+ Webroar::FileHelper.copy(File.join(import_dir,"conf","mail_conf.yml"), File.join(WEBROAR_ROOT, "conf"))
+
+ # Copy conf/server_internal_config.yml file.
+ example = YAML.load(File.open(File.join(WEBROAR_ROOT, "conf", "server_internal_config.example.yml")))
+ old = YAML.load(File.open(File.join(import_dir, "conf", "server_internal_config.yml")))
+ if example and old
+ new = example.merge(old).delete_if{ |key, value| !example.has_key?(key)}
+ dump = YAML::dump(new).gsub(/: true/, ': on').gsub(/: false/, ': off')
+ file = File.open(File.join(WEBROAR_ROOT, "conf", "server_internal_config.yml"), "w")
+ file.puts dump
+ file.close
+ end
+
configuration = YAML.load(File.open(DB_CONFIG_FILE))["production"]
if configuration['adapter'] == 'sqlite3' and configuration['database'][0,1] != "/"
db = File.join(import_dir, "src", "admin_panel", configuration['database'])
- FileUtils.copy(db, File.join(ADMIN_PANEL_DIR, configuration['database'])) if File.exist?(db)
+ Webroar::FileHelper.copy(db, File.join(ADMIN_PANEL_DIR, configuration['database']))
end
puts "done."
return YAML.load(File.open(WEBROAR_CONFIG_FILE))["Server Specification"]["port"]
@@ -790,4 +807,4 @@ def remove_softlink(file)
end #class Installer
end #module Command
-end #module Webroar
+end #module Webroar
View
@@ -346,7 +346,7 @@ def stop_webroar
sleep(1)
# Remove all temporary files
- FileUtils.rm Dir.glob('/tmp/webroar_*')
+ Webroar::FileHelper.remove('/tmp/webroar_*')
rescue => err
puts err
puts err.backtrace
View
@@ -16,12 +16,34 @@
# You should have received a copy of the GNU General Public License
# along with WebROaR. If not, see <http://www.gnu.org/licenses/>.
+require "fileutils"
+
module Webroar
class User
def self.permitted?
return true if File.writable?(TESTFILE)
puts "#{MESSAGE_DEPLOYMENT}"
return false
end
+ end
+
+ class FileHelper
+ def self.copy(src, dest)
+ return false unless File.exist?(src)
+ FileUtils.copy(src, dest)
+ return true
+ end
+
+ def self.move(src, dest)
+ return false unless File.exist?(src)
+ FileUtils.move(src, dest)
+ return true
+ end
+
+ def self.remove(src)
+ return false unless File.exist?(src)
+ FileUtils.remove(src)
+ return true
+ end
end
end # module Webroar
View
@@ -76,6 +76,7 @@ spec = Gem::Specification.new do |s|
File.join('src', 'admin_panel', 'test.log'),
File.join('src', 'admin_panel', 'test_summary'),
File.join('conf', 'mail_config.yml'),
+ File.join('conf', 'server_internal_config.yml'),
File.join('conf', 'config.yml'))
s.test_files = FileList[File.join('test', '**', '*.{c,h,yml,rb,js,css,html,txt}'),

0 comments on commit 45f10fb

Please sign in to comment.