2014-04-15 19:08:43 +01:00
|
|
|
class RestartNodesJob
|
2014-04-15 19:41:06 +01:00
|
|
|
@queue = :low
|
2014-04-15 19:08:43 +01:00
|
|
|
|
|
|
|
def self.perform
|
2014-04-17 20:08:22 +01:00
|
|
|
return if NodeInstruction.all_locked?
|
2014-04-17 21:18:24 +01:00
|
|
|
available_nodes = RpmBuildNode.all.map{ |n| n.user_id if n.user.try(:system?) }.compact.uniq
|
2014-04-15 19:08:43 +01:00
|
|
|
NodeInstruction.where(status: NodeInstruction::READY).
|
2014-04-17 20:15:35 +01:00
|
|
|
where.not(user_id: available_nodes).find_each(&:restart)
|
2014-04-15 19:08:43 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|