-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtrigger_detached_run.rb
More file actions
47 lines (34 loc) · 1.16 KB
/
trigger_detached_run.rb
File metadata and controls
47 lines (34 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'dotenv'
Dotenv.load
require_relative "lib/sentry_init"
begin
require 'optparse'
APPS = ["rdvi", "rdvsp", "rdvs"].freeze
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: #{$0} --app APP"
opts.on("-a", "--app APP", "Specify the app (rdvi, rdvsp, rdvs)") do |a|
options[:app] = a
end
end.parse!
app = options[:app]
raise ArgumentError, "App option is required" if app.nil?
unless APPS.include?(app)
raise ArgumentError, "App must be one of: #{APPS.join(', ')}"
end
if system("which scalingo")
puts "⏭️ scalingo-cli already installed…"
else
res = system("install-scalingo-cli")
raise "❌ Failed to install scalingo CLI" unless res
end
# scalingo is auto logged in via environment variable SCALINGO_API_TOKEN
command = %[scalingo --region osc-secnum-fr1 --app rdv-service-public-etl run --detached "bundle exec ruby main.rb --from-cron --app #{app}"]
puts "Executing command: #{command}…"
res = system(command)
raise "❌ Failed to trigger detached run" unless res
puts "✅ Detached run triggered for app: #{app}"
rescue Exception => e
Sentry.capture_exception(e)
raise e
end