|
|
|
@ -498,44 +498,41 @@ class GamesController < ApplicationController
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
# 思路: 异常首先应该考虑去恢复
|
|
|
|
|
# retry为1表示已经轮训完成后还没有解决问题,这个时候需要检测异常
|
|
|
|
|
if params[:retry].to_i == 1
|
|
|
|
|
begin
|
|
|
|
|
# 如果模板没有问题,则通过中间层检测实训仓库是否异常
|
|
|
|
|
# 监测版本库HEAD是否存在,不存在则取最新的HEAD
|
|
|
|
|
gitUrl = repo_url @myshixun.repo_path
|
|
|
|
|
gitUrl = Base64.urlsafe_encode64(gitUrl)
|
|
|
|
|
shixun_tomcat = edu_setting('cloud_bridge')
|
|
|
|
|
rep_params = {:tpiID => "#{@myshixun.id}", :tpiGitURL => "#{gitUrl}"}
|
|
|
|
|
# 监测版本库HEAD是否存在,不存在则取最新的HEAD
|
|
|
|
|
uri = "#{shixun_tomcat}/bridge/game/check"
|
|
|
|
|
res = uri_post uri, rep_params
|
|
|
|
|
uid_logger("repo_content to bridge: res is #{res}")
|
|
|
|
|
# res值:0 表示正常;-1表示有错误;-2表示代码版本库没了
|
|
|
|
|
#
|
|
|
|
|
if status == 0 && res
|
|
|
|
|
# 版本库报错,修复不了
|
|
|
|
|
if res['code'] == -1 || res['code'] == -2
|
|
|
|
|
begin
|
|
|
|
|
# GitService.delete_repository(repo_path: @myshixun.repo_path) if res['code'] == -1
|
|
|
|
|
project_fork(@myshixun, @shixun.repo_path, current_user.login)
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger_error("#{e.message}")
|
|
|
|
|
tip_exception("#{e.message}")
|
|
|
|
|
end
|
|
|
|
|
begin
|
|
|
|
|
# 如果模板没有问题,则通过中间层检测实训仓库是否异常
|
|
|
|
|
# 监测版本库HEAD是否存在,不存在则取最新的HEAD
|
|
|
|
|
gitUrl = repo_url @myshixun.repo_path
|
|
|
|
|
gitUrl = Base64.urlsafe_encode64(gitUrl)
|
|
|
|
|
shixun_tomcat = edu_setting('cloud_bridge')
|
|
|
|
|
rep_params = {:tpiID => "#{@myshixun.id}", :tpiGitURL => "#{gitUrl}"}
|
|
|
|
|
# 监测版本库HEAD是否存在,不存在则取最新的HEAD
|
|
|
|
|
uri = "#{shixun_tomcat}/bridge/game/check"
|
|
|
|
|
res = uri_post uri, rep_params
|
|
|
|
|
uid_logger("repo_content to bridge: res is #{res}")
|
|
|
|
|
# res值:0 表示正常;-1表示有错误;-2表示代码版本库没了
|
|
|
|
|
#
|
|
|
|
|
if status == 0 && res
|
|
|
|
|
# 版本库报错,修复不了
|
|
|
|
|
if res['code'] == -1 || res['code'] == -2
|
|
|
|
|
begin
|
|
|
|
|
# GitService.delete_repository(repo_path: @myshixun.repo_path) if res['code'] == -1
|
|
|
|
|
project_fork(@myshixun, @shixun.repo_path, current_user.login)
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger_error("#{e.message}")
|
|
|
|
|
tip_exception("#{e.message}")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
|
end
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
|
|
|
|
|
|
if @myshixun.shixun.try(:status) < 2
|
|
|
|
|
tip_exception("代码获取异常,请检查实训模板的评测设置是否正确")
|
|
|
|
|
else
|
|
|
|
|
# 报错继续retry
|
|
|
|
|
tip_exception(-3, "#{e.message}")
|
|
|
|
|
end
|
|
|
|
|
if @myshixun.shixun.try(:status) < 2
|
|
|
|
|
tip_exception("代码获取异常,请检查实训模板的评测设置是否正确")
|
|
|
|
|
else
|
|
|
|
|
# 报错继续retry
|
|
|
|
|
tip_exception(-3, "#{e.message}")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
# 有异常,版本库获取不到代码,前端轮训15S后,调用retry == 1
|
|
|
|
|
tip_exception(0, e.message)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|