diff --git a/lib/tasks/site.rake b/lib/tasks/site.rake index 2bf17207a..5e5450d6e 100644 --- a/lib/tasks/site.rake +++ b/lib/tasks/site.rake @@ -20,28 +20,28 @@ namespace :site do task :necessary_data => :environment do puts "Enter your resque namespace[Orbit]:......" - resque_namespace = gets.chomp - resque_namespace = APP_CONFIG['orbit'] if resque_namespace.empty? + @resque_namespace = STDIN.gets.gsub("\n",'') + @resque_namespace = APP_CONFIG['orbit'] if @resque_namespace.empty? puts "Is this a primary site?[Default No]:......" - site_is_primary = False - site_is_primary = gets.chomp - site_is_primary = True if site_is_primary.downcase == 'yes' + site_is_primary = false + site_is_primary = STDIN.gets.gsub("\n",'') + site_is_primary = true if site_is_primary.downcase == 'yes' - resque_setting = ERB.new(File.new("#{$script_root}/lib/template/setting/resque.god.erb").read) - File.open("#{nginx_root}/config/resque.god", 'w') { |file| file.write(resque_setting.result) } + 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) } - resque_schedule_setting = ERB.new(File.new("#{$script_root}/lib/template/setting/resque_schedule.god.erb").read) - File.open("#{nginx_root}/config/resque_schedule.god", 'w') { |file| file.write(resque_schedule_setting.result) } + resque_schedule_setting = ERB.new(File.new("lib/template/setting/resque_schedule.god.erb").read) + File.open("config/resque_schedule.god", 'w') { |file| file.write(resque_schedule_setting.result) } if site_is_primary - solr_setting = ERB.new(File.new("#{$script_root}/lib/template/setting/solr.god.erb").read) - File.open("#{nginx_root}/config/solr.god", 'w') { |file| file.write(solr_setting.result) } + solr_setting = ERB.new(File.new("lib/template/setting/solr.god.erb").read) + File.open("config/solr.god", 'w') { |file| file.write(solr_setting.result) } end site = Site.first site.title = 'RulingOrbit Demo Site' - site.resque_namespace = resque_namespace + site.resque_namespace = @resque_namespace site.save # home_trans = I18nVariable.create!( :document_class => 'Home', :key => 'home', :en => 'Homepage', :zh_tw => '首頁') diff --git a/lib/template/setting/resque.god.erb b/lib/template/setting/resque.god.erb index ec8da83f3..4adbf4f01 100644 --- a/lib/template/setting/resque.god.erb +++ b/lib/template/setting/resque.god.erb @@ -10,7 +10,7 @@ num_workers.times do |num| God.watch do |w| w.dir = rails_root - w.name = "<%= namespace.nil? ? "" : "#{namespace}-" %>resque-worker-#{num}" + w.name = "<%= @resque_namespace.nil? ? "" : "#{@resque_namespace}-" %>resque-worker-#{num}" w.group = 'rulingcom' w.interval = 30.seconds diff --git a/lib/template/setting/resque_schedule.god b/lib/template/setting/resque_schedule.god.erb similarity index 94% rename from lib/template/setting/resque_schedule.god rename to lib/template/setting/resque_schedule.god.erb index 301e1b812..b593b64b6 100644 --- a/lib/template/setting/resque_schedule.god +++ b/lib/template/setting/resque_schedule.god.erb @@ -6,7 +6,7 @@ development_gid = '' God.watch do |w| w.dir = rails_root - w.name = "<%= namespace.nil? ? "" : "#{namespace}-" %>resque-scheduler" + 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} diff --git a/lib/template/setting/solr.god.erb b/lib/template/setting/solr.god.erb index 6b4e6770b..02b5be435 100644 --- a/lib/template/setting/solr.god.erb +++ b/lib/template/setting/solr.god.erb @@ -6,7 +6,7 @@ development_gid = '' God.watch do |w| w.dir = rails_root - w.name = "<%= namespace.nil? ? "" : "#{namespace}-" %>sunspot-solr" + w.name = "<%= @resque_namespace.nil? ? "" : "#{@resque_namespace}-" %>sunspot-solr" w.group = 'rulingcom' w.interval = 30.seconds w.env = {"RAILS_ENV"=>rails_env}