mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
fix: mirror broadcast error and retry
This commit is contained in:
@@ -18,12 +18,29 @@ class BroadcastMirrorRepoMsgJob < ApplicationJob
|
||||
id: project.id,
|
||||
type: project.numerical_for_project_type
|
||||
}
|
||||
# 新增失败重试机制, 重试三次
|
||||
result = broadcast(project, json_data)
|
||||
|
||||
if result == 0
|
||||
count = 3
|
||||
while count > 0
|
||||
result = broadcast(project, json_data)
|
||||
if result > 0
|
||||
break
|
||||
end
|
||||
count -= 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def broadcast(project, json_data)
|
||||
puts "############ broadcast start.......... "
|
||||
puts "############ broadcast channel_name: channel_room_#{project.id}"
|
||||
puts "############ broadcast project data: #{json_data} "
|
||||
|
||||
cable_result = ActionCable.server.broadcast "channel_room_#{project.id}", project: json_data
|
||||
|
||||
puts "############ broadcast result: #{cable_result == 1 ? 'successed' : 'failed'} "
|
||||
puts "############ broadcast result: #{cable_result > 0 ? 'successed' : 'failed'} "
|
||||
return cable_result
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,5 +16,6 @@ class MigrateRemoteRepositoryJob < ApplicationJob
|
||||
else
|
||||
repo&.mirror&.failed!
|
||||
end
|
||||
BroadcastMirrorRepoMsgJob.perform_later(repo.id) unless repo&.mirror.waiting?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,6 +26,7 @@ class SyncMirroredRepositoryJob < ApplicationJob
|
||||
result = Gitea::Repository::SyncMirroredService.call(repo.owner.login,
|
||||
repo.identifier, token: user.gitea_token)
|
||||
repo&.mirror.set_status! if result[:status] === 200
|
||||
BroadcastMirrorRepoMsgJob.perform_later(repo.id) unless repo&.mirror.waiting?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user