|
|
|
@ -1,19 +1,19 @@
|
|
|
|
|
class AddLimitForShixuns < ActiveRecord::Migration
|
|
|
|
|
def up
|
|
|
|
|
if !Challenge.first.has_attribute?(:exec_time)
|
|
|
|
|
add_column :challenges, :exec_time, :integer, :default => 120
|
|
|
|
|
end
|
|
|
|
|
Shixun.find_each do |shixun|
|
|
|
|
|
shixun.challenges.update_all(:exec_time => shixun.exec_time)
|
|
|
|
|
shixun.mirror_repositories.each do |mirror|
|
|
|
|
|
ShixunServiceConfig.create!(:shixun_id => shixun.id,
|
|
|
|
|
:cpu_limit => mirror.cpu_limit,
|
|
|
|
|
:memory_limit => mirror.memory_limit,
|
|
|
|
|
:request_limit => mirror.memory_limit / 3,
|
|
|
|
|
:mirror_repository_id => mirror.id)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# if !Challenge.first.has_attribute?(:exec_time)
|
|
|
|
|
# add_column :challenges, :exec_time, :integer, :default => 120
|
|
|
|
|
# end
|
|
|
|
|
# Shixun.find_each do |shixun|
|
|
|
|
|
# shixun.challenges.update_all(:exec_time => shixun.exec_time)
|
|
|
|
|
# shixun.mirror_repositories.each do |mirror|
|
|
|
|
|
# ShixunServiceConfig.create!(:shixun_id => shixun.id,
|
|
|
|
|
# :cpu_limit => mirror.cpu_limit,
|
|
|
|
|
# :memory_limit => mirror.memory_limit,
|
|
|
|
|
# :request_limit => mirror.memory_limit / 3,
|
|
|
|
|
# :mirror_repository_id => mirror.id)
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|