diff --git a/lib/tasks/site.rake b/lib/tasks/site.rake index 035f479c3..4782fe648 100644 --- a/lib/tasks/site.rake +++ b/lib/tasks/site.rake @@ -18,6 +18,10 @@ namespace :site do Info.create!(key: "profile", built_in: true, disabled: false, title: {"zh_tw"=>"基本欄位", "en"=>"Basic Info"}, to_search: false) end + task :create_logrotate => :environment do #Can remove after all products update + create_rulingcom_logrotate + end + task :necessary_data => :environment do puts "Enter your resque namespace[Orbit]:......" @resque_namespace = STDIN.gets.gsub("\n",'') @@ -44,6 +48,7 @@ namespace :site do if site_is_primary 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) } + create_rulingcom_logrotate end site = Site.first @@ -63,6 +68,24 @@ namespace :site do home.save puts "Rember to restart server after you setup all sites for starting God" + + def create_rulingcom_logrotate + @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? + + @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? + + 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) } + + `sudo cp #{@project_loc}/tmp/logrotate_setting /etc/logrotate.d/rulingcom` + end + end end diff --git a/lib/template/setting/logrotate.erb b/lib/template/setting/logrotate.erb deleted file mode 100644 index be4fe6d59..000000000 --- a/lib/template/setting/logrotate.erb +++ /dev/null @@ -1,16 +0,0 @@ -#Put logrotate setting for Orbit here - - -#Might need partial -/var/log/basedir/*.log /var/log/basedir/*/*.log { - daily - rotate 5 -} - -#Resque -#Orbit -#DB log - - - -#Remember to save this file as /etc/logrotate.d/orbit diff --git a/lib/template/setting/rulingcom_log.erb b/lib/template/setting/rulingcom_log.erb new file mode 100644 index 000000000..15bfdea17 --- /dev/null +++ b/lib/template/setting/rulingcom_log.erb @@ -0,0 +1,25 @@ +/var/log/rulingcom/*.log { + daily + rotate 5 +} + +#Resque +<%= "#{@project_folder}/nginx/logs/access.log" %>{ + daily + rotate 5 +} + +#DB log +/var/log/mongodb{ + daily + rotate 5 +} + +#Orbit +<%= "#{@project_folder}/log/*production.log" %>{ + daily + rotate 5 +} +# end of Orbit,EXTEND IF NEEDED + +#Remember to save this file as /etc/logrotate.d/rulingcom