Reuse runners per user and execution environment

Co-authored-by: Jan-Eric Hellenberg <jan-eric.hellenberg@student.hpi.uni-potsdam.de>
Co-authored-by: Maximilian Pass <maximilian.pass@student.hpi.uni-potsdam.de>
This commit is contained in:
Konrad Hanff
2021-04-19 08:54:05 +02:00
committed by Sebastian Serth
parent 3017e46006
commit 17bd2d8726
12 changed files with 164 additions and 71 deletions

View File

@@ -0,0 +1,3 @@
class ApplicationJob < ActiveJob::Base
queue_as :default
end

View File

@@ -0,0 +1,16 @@
class RunnerCleanupJob < ApplicationJob
CLEANUP_INTERVAL = CodeOcean::Config.new(:code_ocean).read[:runner_management][:cleanup_interval].seconds
after_perform do |job|
# re-schedule job
self.class.set(wait: CLEANUP_INTERVAL).perform_later
end
def perform
Rails.logger.debug(Time.now)
Runner.inactive_runners.each do |runner|
Rails.logger.debug("Destroying runner #{runner.runner_id}, unused since #{runner.last_used}")
runner.destroy
end
end
end