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:

committed by
Sebastian Serth

parent
3017e46006
commit
17bd2d8726
3
app/jobs/application_job.rb
Normal file
3
app/jobs/application_job.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class ApplicationJob < ActiveJob::Base
|
||||
queue_as :default
|
||||
end
|
16
app/jobs/runner_cleanup_job.rb
Normal file
16
app/jobs/runner_cleanup_job.rb
Normal 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
|
Reference in New Issue
Block a user