11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/mutx/background_jobs/workers/alerts_worker.rb', line 11
def perform(args)
stringio = StringIO.new
@alert = Alert.find(name: args['name'])
status = nil
begin
PTY.spawn("ruby #{args['path']}") do |stdout, stdin, pid|
begin
stdout.each do |line|
stringio.puts line
end
rescue Errno::EIO
ensure
Process.wait pid
status = $?.exitstatus
end
end
rescue => e
puts e.message
puts e.backtrace
raise e
ensure
@alert.update_status(status, info: stringio.string)
end
end
|