2011-08-18 05:43:33 +00:00
|
|
|
# encoding: utf-8
|
2013-06-24 08:29:30 +00:00
|
|
|
require 'erb'
|
2011-08-18 05:43:33 +00:00
|
|
|
|
|
|
|
namespace :site do
|
|
|
|
|
|
|
|
task :build => :environment do
|
2013-02-05 10:26:45 +00:00
|
|
|
Site.destroy_all
|
|
|
|
Purchase.destroy_all
|
2013-05-14 03:26:35 +00:00
|
|
|
|
2011-11-22 10:54:10 +00:00
|
|
|
Site.create( :school => 'RulingDigital University', :department => 'Computer Science', :valid_locales => [ 'en', 'zh_tw' ], :in_use_locales => [ 'zh_tw', 'en' ])
|
2013-05-14 02:32:53 +00:00
|
|
|
User.create!(:email=>'chris@rulingcom.com',:admin=>true,:user_id=>'chris',:password=>'password')
|
2013-05-14 03:26:35 +00:00
|
|
|
`mongo #{Mongoid.config.database.name} --eval "db.fs.chunks.ensureIndex({files_id: 1, n: 1})"`
|
2013-06-24 08:29:30 +00:00
|
|
|
|
2013-05-14 03:26:35 +00:00
|
|
|
puts "Congres you can now login within url"
|
|
|
|
puts 'Please upload design package (/admin/designs/upload_package ) and run rake site:necessary_data'
|
2013-05-14 03:48:13 +00:00
|
|
|
I18nVariable.create!( :document_class => 'language', :key => 'en', :en => 'English', :zh_tw => '英文' )
|
|
|
|
I18nVariable.create!( :document_class => 'language', :key => 'zh_tw', :en => 'Chinese', :zh_tw => '中文' )
|
2013-06-24 08:29:30 +00:00
|
|
|
Info.create!(key: "profile", built_in: true, disabled: false, title: {"zh_tw"=>"基本欄位", "en"=>"Basic Info"}, to_search: false)
|
2011-08-18 05:43:33 +00:00
|
|
|
end
|
|
|
|
|
2013-07-03 10:00:32 +00:00
|
|
|
task :create_logrotate => :environment do #Can remove after all products update
|
|
|
|
create_rulingcom_logrotate
|
|
|
|
end
|
|
|
|
|
2013-05-14 02:32:53 +00:00
|
|
|
task :necessary_data => :environment do
|
2013-07-04 04:13:05 +00:00
|
|
|
auto_setting
|
|
|
|
site = Site.first
|
2013-08-27 10:37:09 +00:00
|
|
|
site.update_attribute(:title,'RulingOrbit Demo Site')
|
|
|
|
site.update_attribute(:resque_namespace,@resque_namespace)
|
2013-07-04 04:13:05 +00:00
|
|
|
|
|
|
|
# home_trans = I18nVariable.create!( :document_class => 'Home', :key => 'home', :en => 'Homepage', :zh_tw => '首頁')
|
|
|
|
design = Design.first
|
|
|
|
site.design = design
|
|
|
|
site.save
|
|
|
|
theme = design.themes.first
|
|
|
|
home = Page.new( :design_id => design.id, :name => 'home', :is_published => true, :theme_id => theme.id )
|
|
|
|
|
|
|
|
home.title_translations = {"zh_tw"=>"首頁", "en"=>"Home"}
|
|
|
|
home.save
|
|
|
|
|
|
|
|
puts "Rember to restart server after you setup all sites for starting God"
|
|
|
|
end
|
|
|
|
|
|
|
|
task :start_auto_setting => :environment do
|
|
|
|
auto_setting
|
|
|
|
end
|
|
|
|
|
|
|
|
def auto_setting
|
2013-06-24 08:29:30 +00:00
|
|
|
puts "Enter your resque namespace[Orbit]:......"
|
2013-06-26 04:58:50 +00:00
|
|
|
@resque_namespace = STDIN.gets.gsub("\n",'')
|
|
|
|
@resque_namespace = APP_CONFIG['orbit'] if @resque_namespace.empty?
|
2013-06-24 08:29:30 +00:00
|
|
|
|
2013-08-27 10:37:09 +00:00
|
|
|
|
2013-08-27 09:28:33 +00:00
|
|
|
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'
|
|
|
|
|
2013-06-24 08:29:30 +00:00
|
|
|
puts "Is this a primary site?[Default No]:......"
|
2013-06-26 04:58:50 +00:00
|
|
|
site_is_primary = false
|
|
|
|
site_is_primary = STDIN.gets.gsub("\n",'')
|
|
|
|
site_is_primary = true if site_is_primary.downcase == 'yes'
|
2013-06-24 08:29:30 +00:00
|
|
|
|
2013-08-27 09:28:33 +00:00
|
|
|
puts "Traffic heavy?[Default No]:......"
|
|
|
|
traffic_heavy = false
|
|
|
|
traffic_heavy = STDIN.gets.gsub("\n",'')
|
2013-08-29 10:08:33 +00:00
|
|
|
traffic_heavy = true if traffic_heavy.downcase == 'yes'
|
2013-07-03 04:57:43 +00:00
|
|
|
|
2013-08-27 09:28:33 +00:00
|
|
|
@traffic_rate = traffic_heavy ? 2 : 1
|
2013-07-03 04:57:43 +00:00
|
|
|
|
2013-08-27 09:28:33 +00:00
|
|
|
if site_is_alone
|
2013-08-27 10:37:09 +00:00
|
|
|
@resque_workers = 5 * @traffic_rate #Entry Site
|
2013-08-27 09:28:33 +00:00
|
|
|
else
|
|
|
|
if site_is_primary
|
2013-08-27 10:37:09 +00:00
|
|
|
@resque_workers = 2 * @traffic_rate #Primary Site
|
2013-08-27 09:28:33 +00:00
|
|
|
else
|
2013-08-27 10:37:09 +00:00
|
|
|
@resque_workers = 1 * @traffic_rate #Secondary Site
|
2013-08-27 09:28:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-26 04:58:50 +00:00
|
|
|
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) }
|
2013-06-24 08:29:30 +00:00
|
|
|
|
2013-06-26 04:58:50 +00:00
|
|
|
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) }
|
2013-06-24 08:29:30 +00:00
|
|
|
|
|
|
|
if site_is_primary
|
2013-06-26 04:58:50 +00:00
|
|
|
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) }
|
2013-07-03 10:00:32 +00:00
|
|
|
create_rulingcom_logrotate
|
2013-06-24 08:29:30 +00:00
|
|
|
end
|
2013-07-04 04:13:05 +00:00
|
|
|
end
|
2013-06-24 08:29:30 +00:00
|
|
|
|
2013-07-03 10:00:32 +00:00
|
|
|
|
2013-07-04 04:13:05 +00:00
|
|
|
def create_rulingcom_logrotate
|
|
|
|
`sudo mkdir -p /var/log/rulingcom` unless File.directory? "/var/log/rulingcom"
|
|
|
|
@project_folder = ENV["PWD"]
|
|
|
|
puts "Is your Orbit folder: #{@project_folder} (If YES => Press enter,or enter your path)"
|
|
|
|
user_enter_project_folder = STDIN.gets.gsub("\n",'')
|
|
|
|
@project_folder = user_enter_project_folder unless user_enter_project_folder.empty?
|
2013-07-03 10:00:32 +00:00
|
|
|
|
2013-07-04 04:13:05 +00:00
|
|
|
@user_home_folder = ENV["HOME"]
|
|
|
|
puts "Is your Home folder: #{@user_home_folder} (If YES => Press enter,or enter your path)"
|
|
|
|
user_enter_home_folder = STDIN.gets.gsub("\n",'')
|
|
|
|
@user_home_folder = user_enter_home_folder unless user_enter_home_folder.empty?
|
2013-07-03 10:00:32 +00:00
|
|
|
|
2013-07-04 04:13:05 +00:00
|
|
|
logrotate_setting = ERB.new(File.new("lib/template/setting/rulingcom_log.erb").read)
|
|
|
|
File.open("#{@project_loc}/tmp/logrotate_setting", 'w') { |file| file.write(logrotate_setting.result) }
|
2013-07-03 10:00:32 +00:00
|
|
|
|
2013-07-04 04:13:05 +00:00
|
|
|
`sudo cp #{@project_loc}/tmp/logrotate_setting /etc/logrotate.d/rulingcom`
|
2013-07-04 04:28:11 +00:00
|
|
|
`logrotate -v -f /etc/logrotate.conf`
|
2013-07-04 04:13:05 +00:00
|
|
|
end
|
2013-05-14 02:32:53 +00:00
|
|
|
|
2011-08-18 05:43:33 +00:00
|
|
|
end
|