13996: More config migrations, refactor some code into config_loader.rb
[arvados.git] / services / api / script / fail-jobs.rb
1 #!/usr/bin/env ruby
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 require 'optimist'
7
8 opts = Optimist::options do
9   banner 'Fail jobs that have state=="Running".'
10   banner 'Options:'
11   opt(:before,
12       'fail only jobs that started before the given time (or "reboot")',
13       type: :string)
14 end
15
16 ENV["RAILS_ENV"] = ARGV[0] || ENV["RAILS_ENV"] || "development"
17 require File.dirname(__FILE__) + '/../config/boot'
18 require File.dirname(__FILE__) + '/../config/environment'
19 require Rails.root.join('lib/crunch_dispatch.rb')
20
21 CrunchDispatch.new.fail_jobs before: opts[:before]