#778: integrate FileSystemWorker with Platforms and Repositories

This commit is contained in:
Vokhmin Alexey V 2012-12-13 21:38:04 +04:00
parent 728a40658c
commit 07d0ed89b4
5 changed files with 20 additions and 68 deletions

View File

@ -197,21 +197,15 @@ class Platform < ActiveRecord::Base
end
def xml_rpc_create
result = BuildServer.add_platform name, APP_CONFIG['root_path'] + '/platforms' , distrib_type
if result == BuildServer::SUCCESS
return true
else
raise "Failed to create platform #{name} with code #{result}. Path: #{build_path(name)}"
end
Resque.enqueue(AbfWorker::FileSystemWorker,
{:id => id, :action => 'create', :type => 'platform'})
return true
end
def xml_rpc_destroy
result = BuildServer.delete_platform name
if result == BuildServer::SUCCESS
return true
else
raise "Failed to delete platform #{name} with code #{result}."
end
Resque.enqueue(AbfWorker::FileSystemWorker,
{:id => id, :action => 'destroy', :type => 'platform'})
return true
end
def xml_rpc_clone(old_name = parent.name, new_name = name)

View File

@ -61,6 +61,7 @@ class Repository < ActiveRecord::Base
protected
# TODO: remove it, when will be used new_core only.
def xml_rpc_create
result = BuildServer.create_repo name, platform.name
if result == BuildServer::SUCCESS
@ -71,11 +72,8 @@ class Repository < ActiveRecord::Base
end
def xml_rpc_destroy
result = BuildServer.delete_repo name, platform.name
if result == BuildServer::SUCCESS
return true
else
raise "Failed to delete repository #{name} inside platform #{platform.name} with code #{result}."
end
Resque.enqueue(AbfWorker::FileSystemWorker,
{:id => id, :action => 'destroy', :type => 'repository'})
return true
end
end

View File

@ -9,8 +9,6 @@ module AbfWorker
@runner = AbfWorker::Runners::Platform.new id, action
when 'repository'
@runner = AbfWorker::Runners::Repository.new id, action
when 'project'
@runner = AbfWorker::Runners::Project.new id, action
end
@runner.run
end

View File

@ -10,19 +10,6 @@ module AbfWorker
protected
def create
platform = @repository.platform
repository_path = platform.path
repository_path << '/repository'
if platform.personal?
Platform.main.pluck(:name).each do |main_platform_name|
create_file_tree "#{repository_path}/#{main_platform_name}", true
end
else
create_file_tree repository_path
end
end
def destroy
platform = @repository.platform
repository_path = platform.path
@ -43,40 +30,6 @@ module AbfWorker
system("rm -rf #{repository_path}/SRPMS/#{@repository.name}")
end
def create_file_tree(repository_path, personal = false)
# platforms/rosa2012.1/repository
# platforms/test_personal/repository/rosa2012.1
mk_dir repository_path
Arch.pluck(:name).each do |arch|
path = "#{repository_path}/#{arch}"
# platforms/rosa2012.1/repository/i586
# platforms/test_personal/repository/rosa2012.1/i586
mk_dir path
path << '/' << @repository.name
# platforms/rosa2012.1/repository/i586/main
# platforms/test_personal/repository/rosa2012.1/i586/main
mk_dir path
# platforms/rosa2012.1/repository/i586/main/release
# platforms/test_personal/repository/rosa2012.1/i586/main/release
mk_dir "#{path}/release"
# platforms/rosa2012.1/repository/i586/main/updates
mk_dir "#{path}/updates" unless personal
end
path = "#{repository_path}/SRPMS"
# platforms/rosa2012.1/repository/SRPMS
# platforms/test_personal/repository/rosa2012.1/SRPMS
mk_dir path
path << '/' << @repository.name
# platforms/rosa2012.1/repository/SRPMS/main
# platforms/test_personal/repository/rosa2012.1/SRPMS/main
mk_dir path
# platforms/rosa2012.1/repository/SRPMS/main/release
# platforms/test_personal/repository/rosa2012.1/SRPMS/main/release
mk_dir "#{path}/release"
# platforms/rosa2012.1/repository/SRPMS/main/updates
mk_dir "#{path}/updates" unless personal
end
end
end
end

View File

@ -26,7 +26,16 @@ Capistrano::Configuration.instance(:must_exist).load do
end
def start_workers
run "cd #{fetch :current_path} && COUNT=#{workers_count} QUEUE=fork_import,hook,clone_build,notification,iso_worker_observer,rpm_worker_observer #{rails_env} BACKGROUND=yes bundle exec rake resque:workers"
queue = [
:fork_import,
:hook,
:clone_build,
:notification,
:iso_worker_observer,
:rpm_worker_observer,
:file_system_worker
].join(',')
run "cd #{fetch :current_path} && COUNT=#{workers_count} QUEUE=#{queue} #{rails_env} BACKGROUND=yes bundle exec rake resque:workers"
end
end
end