Downloads and Rsync mount with sudo refactor

This commit is contained in:
konstantin.grabar 2011-12-08 11:42:12 +04:00
parent 26689f3bd2
commit 25f06edb65
3 changed files with 18 additions and 6 deletions

View File

@ -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={})

View File

@ -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)

View File

@ -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