改动sleep时间

This commit is contained in:
huang 2017-02-28 21:11:14 +08:00
parent 7804ea69bd
commit cfd2161756
2 changed files with 9 additions and 6 deletions

View File

@ -895,8 +895,7 @@ class ProjectsController < ApplicationController
gitlab_address = Redmine::Configuration['gitlab_address']
gitUrl = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ rep_identify + "."+"git"
gitUrl = Base64.encode64(gitUrl)
@page = params[:page] ? params[:page].to_i + 1 : 0
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'TrainingTask','Message','News', 'Project', 'Attachment','Commit')", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10)
if @training_task.status == 0
params = {:jobName => "#{jobName}", :taskId => "#{taskId}", :step => "#{step}", :gitUrl => "#{gitUrl}"}
uri = URI.parse("http://123.59.135.74:9999/jenkins-exec/api/buildJob")
@ -905,8 +904,8 @@ class ProjectsController < ApplicationController
# 任务开启成功后创建一条留言提示,并发布
# @training_task.update_attribute(:status, 2)
# 轮询获取
for i in 0..10 do
sleep(10)
for i in 0..30 do
sleep(2)
status = TrainingTask.where(:id => @training_task.id).first.try(:status)
if (status == 1 || status == 0)
@training_task.status = status
@ -917,11 +916,15 @@ class ProjectsController < ApplicationController
end
end
return
@page = params[:page] ? params[:page].to_i + 1 : 0
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'TrainingTask','Message','News', 'Project', 'Attachment','Commit')", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10)
rescue Exception => e
puts e
end
end
respond_to do |format|
format.js
end
end
def uri_exec uri, params