X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e46ae4015db8f166359515f2e9823ac1a2c7cab8..c912d9d8d9e2a055a53967c5b01242c321dfbeb6:/services/api/script/crunch-dispatch.rb diff --git a/services/api/script/crunch-dispatch.rb b/services/api/script/crunch-dispatch.rb index ecc7f5d98e..693dfbdb7f 100755 --- a/services/api/script/crunch-dispatch.rb +++ b/services/api/script/crunch-dispatch.rb @@ -38,6 +38,7 @@ class Dispatcher def refresh_todo @todo = Job.queue + @todo_pipelines = PipelineInstance.queue end def sinfo @@ -314,6 +315,17 @@ class Dispatcher @running.delete job_done.uuid end + def update_pipelines + @todo_pipelines.each do |p| + pipe_auth = ApiClientAuthorization. + new(user: User.where('uuid=?', p.modified_by_user_uuid).first, + api_client_id: 0) + pipe_auth.save + + puts `export ARVADOS_API_TOKEN=#{pipe_auth.api_token} && arv-run-pipeline-instance --run-here --no-wait --instance #{p.uuid}` + end + end + def run act_as_system_user @running ||= {} @@ -338,6 +350,9 @@ class Dispatcher unless @todo.empty? or did_recently(:start_jobs, 1.0) or $signal[:term] start_jobs end + unless @todo_pipelines.empty? or did_recently(:update_pipelines, 5.0) + update_pipelines + end end reap_children select(@running.values.collect { |j| [j[:stdout], j[:stderr]] }.flatten, @@ -345,6 +360,8 @@ class Dispatcher end end + + protected def did_recently(thing, min_interval)