fixing setting template and site init scripts
This commit is contained in:
parent
aa8523c8cf
commit
d8dd68b4df
|
@ -51,18 +51,33 @@ namespace :site do
|
|||
@resque_namespace = STDIN.gets.gsub("\n",'')
|
||||
@resque_namespace = APP_CONFIG['orbit'] if @resque_namespace.empty?
|
||||
|
||||
puts "Is this the only site [ Entry site? ] on this mechine?[Default No]:......"
|
||||
site_is_alone = false
|
||||
site_is_alone = STDIN.gets.gsub("\n",'')
|
||||
site_is_alone = true if site_is_alone.downcase == 'yes'
|
||||
|
||||
puts "Is this a primary site?[Default No]:......"
|
||||
site_is_primary = false
|
||||
site_is_primary = STDIN.gets.gsub("\n",'')
|
||||
site_is_primary = true if site_is_primary.downcase == 'yes'
|
||||
|
||||
puts "Is this the only site on this mechine?[Default No]:......"
|
||||
site_is_alone = false
|
||||
site_is_alone = STDIN.gets.gsub("\n",'')
|
||||
site_is_alone = true if site_is_alone.downcase == 'yes'
|
||||
puts "Traffic heavy?[Default No]:......"
|
||||
traffic_heavy = false
|
||||
traffic_heavy = STDIN.gets.gsub("\n",'')
|
||||
traffic_heavy = true if site_is_primary.downcase == 'yes'
|
||||
|
||||
@resque_workers = site_is_alone ? 5 : 2
|
||||
@traffic_rate = traffic_heavy ? 2 : 1
|
||||
|
||||
if site_is_alone
|
||||
@resque_workers = 5 * traffic_rate #Entry Site
|
||||
else
|
||||
if site_is_primary
|
||||
@resque_workers = 2 * traffic_rate #Primary Site
|
||||
else
|
||||
@resque_workers = 1 * traffic_rate #Secondary Site
|
||||
end
|
||||
end
|
||||
|
||||
resque_setting = ERB.new(File.new("lib/template/setting/resque.god.erb").read)
|
||||
File.open("config/resque.god", 'w') { |file| file.write(resque_setting.result) }
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ user_home = ENV['HOME'] || File.dirname(__FILE__) + '/../..'
|
|||
development_uid = ''
|
||||
development_gid = ''
|
||||
|
||||
num_workers = rails_env == 'production' ? <%= @resque_workers %> : 2
|
||||
num_workers = rails_env == 'production' ? <%= @resque_workers %> : 1
|
||||
|
||||
num_workers.times do |num|
|
||||
God.watch do |w|
|
||||
|
@ -16,17 +16,16 @@ num_workers.times do |num|
|
|||
w.interval = 30.seconds
|
||||
|
||||
queue = case num
|
||||
when 0
|
||||
'critical'
|
||||
when 1..2
|
||||
when 0..2
|
||||
'high,low'
|
||||
when 3..num_workers
|
||||
'low'
|
||||
end
|
||||
|
||||
w.env = {"QUEUE"=>queue, "RAILS_ENV"=>rails_env}
|
||||
w.start = "HOME=#{user_home} QUEUE=* RAILS_ENV=#{rails_env} rake -f #{rails_root}/Rakefile resque:work"
|
||||
|
||||
w.pid_file = "#{rails_root}/tmp/#{w.name}.pid"
|
||||
w.env = {"RAILS_ENV"=>rails_env,"PIDFILE" => w.pid_file ,"HOME"=>user_home, "QUEUE"=>queue, "RAILS_ENV"=>rails_env }
|
||||
w.start = "rake -f #{rails_root}/Rakefile resque:work"
|
||||
w.stop = "sudo kill -KILL $(cat #{w.pid_file})"
|
||||
w.uid = (rails_env == 'production' )? "root" : development_uid
|
||||
w.gid = (rails_env == 'production' )? "root" : development_gid
|
||||
|
||||
|
|
|
@ -8,14 +8,16 @@ development_gid = ''
|
|||
w.dir = rails_root
|
||||
w.name = "<%= @resque_namespace.nil? ? "" : "#{@resque_namespace}-" %>resque-scheduler"
|
||||
w.group = 'rulingcom'
|
||||
w.interval = 30.seconds
|
||||
w.env = {"QUEUE"=>"critical,high,low", "RAILS_ENV"=>rails_env}
|
||||
w.start = "HOME=#{user_home} QUEUE=* RAILS_ENV=#{rails_env} rake -f #{rails_root}/Rakefile resque:scheduler"
|
||||
w.interval = 10.seconds
|
||||
w.pid_file = "#{rails_root}/tmp/#{w.name}.pid"
|
||||
|
||||
w.env = {"QUEUE"=>"*", "RAILS_ENV"=>rails_env,"HOME"=>user_home, "RAILS_ENV"=>rails_env}
|
||||
w.start = "rake -f #{rails_root}/Rakefile resque:scheduler"
|
||||
w.stop = "sudo kill -KILL $(cat #{w.pid_file})"
|
||||
w.uid = (rails_env == 'production' )? "root" : development_uid
|
||||
w.gid = (rails_env == 'production' )? "root" : development_gid
|
||||
|
||||
w.log = (rails_env == 'production' )? "/var/log/#{w.group}/#{w.name}.log":"#{rails_root}/log/dev-#{w.name}.log"
|
||||
w.log = (rails_env == 'production' )? "/var/log/#{w.group}/#{w.name}.log":"#{rails_root}/log/dev-#{w.name}.log"
|
||||
|
||||
# restart if memory gets too high
|
||||
w.transition(:up, :restart) do |on|
|
||||
|
|
|
@ -8,13 +8,16 @@ development_gid = ''
|
|||
w.dir = rails_root
|
||||
w.name = "<%= @resque_namespace.nil? ? "" : "#{@resque_namespace}-" %>sunspot-solr"
|
||||
w.group = 'rulingcom'
|
||||
w.interval = 30.seconds
|
||||
w.env = {"RAILS_ENV"=>rails_env}
|
||||
w.start = "HOME=#{user_home} QUEUE=* RAILS_ENV=#{rails_env} rake -f #{rails_root}/Rakefile sunspot:solr:start"
|
||||
w.pid_file = "#{rails_root}/solr/pids/production/sunspot-solr-production.pid"
|
||||
|
||||
w.env = {"RAILS_ENV"=>rails_env,"HOME"=>user_home ,"RAILS_ENV"=>rails_env}
|
||||
w.start = "rake -f #{rails_root}/Rakefile sunspot:solr:start"
|
||||
w.stop = "sudo kill -KILL $(cat #{w.pid_file})"
|
||||
w.keepalive
|
||||
|
||||
w.uid = (rails_env == 'production' )? "root" : development_uid
|
||||
w.gid = (rails_env == 'production' )? "root" : development_gid
|
||||
w.pid_file = "#{rails_root}/solr/pids/production/sunspot-solr-production.pid"
|
||||
|
||||
w.log = (rails_env == 'production' )? "/var/log/#{w.group}/#{w.name}.log":"#{rails_root}/log/dev-#{w.name}.log"
|
||||
|
||||
# restart if memory gets too high
|
||||
|
|
Loading…
Reference in New Issue