diff --git a/app/models/download.rb b/app/models/download.rb index f2b6ce216..3623ad8b3 100644 --- a/app/models/download.rb +++ b/app/models/download.rb @@ -4,6 +4,11 @@ class Download < ActiveRecord::Base default_scope order(:name) class << self + def rotate_nginx_log + system("sudo mv #{ APP_CONFIG['nginx_log'] } #{ APP_CONFIG['nginx_log'] }.0") + system("sudo /etc/init.d/nginx reload") + end + def parse_nginx_log File.open(PREV_LOG_FILE) do |log| while (line = log.gets) @@ -21,7 +26,7 @@ class Download < ActiveRecord::Base def parse_and_remove_nginx_log parse_nginx_log - #system("rm -f #{PREV_LOG_FILE}") + system("sudo rm -f #{PREV_LOG_FILE}") end def increase(opts={}) diff --git a/app/models/platform.rb b/app/models/platform.rb index fbc14ba34..f81b8ea63 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -106,8 +106,12 @@ class Platform < ActiveRecord::Base end def mount_directory_for_rsync - FileUtils.rm_rf "#{ Rails.root.join('tmp', 'umount', self.name) }" if File.exist? "#{ Rails.root.join('tmp', 'umount', name) }" - FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'mount', name) }" + #FileUtils.rm_rf "#{ Rails.root.join('tmp', 'umount', self.name) }" if File.exist? "#{ Rails.root.join('tmp', 'umount', name) }" + #FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'mount', name) }" + system("sudo mkdir -p \"/srv/rosa_build/shared/downloads/#{ name }\"") + system("sudo mount --bind \"/home/share/platforms/#{ name }\" \"/srv/rosa_build/shared/downloads/#{ name }\"") + system("sudo cp -f /srv/rosa_build/current/tmp/mount/#{ name }/* /home/share/platforms/#{ name }/repository/") + system("sudo rm -Rf \"/srv/rosa_build/current/tmp/mount/#{ name }\"") Arch.all.each do |arch| host = EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host] url = "http://#{host}/downloads/#{name}/repository/" @@ -117,8 +121,11 @@ class Platform < ActiveRecord::Base end def umount_directory_for_rsync - FileUtils.rm_rf "#{ Rails.root.join('tmp', 'mount', name) }" if File.exist? "#{ Rails.root.join('tmp', 'mount', name) }" - FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'umount', name) }" + system("umount \"/srv/rosa_build/shared/downloads/#{ name }\"") + system("rm -Rf \"/srv/rosa_build/shared/downloads/#{ name }\"") + system("rm -Rf \"/srv/rosa_build/current/tmp/umount/#{ name }\"") + #FileUtils.rm_rf "#{ Rails.root.join('tmp', 'mount', name) }" if File.exist? "#{ Rails.root.join('tmp', 'mount', name) }" + #FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'umount', name) }" end def make_admin_relation(user_id) diff --git a/config/schedule.rb b/config/schedule.rb index 570fab94a..d71f69a16 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -8,6 +8,6 @@ every 5.minutes do rake "sudo_test:projects" -# runner "Download.rotate_nginx_log" + runner "Download.rotate_nginx_log" runner "Download.parse_and_remove_nginx_log" end