【发布时间】:2016-11-25 06:18:33
【问题描述】:
我正在构建一个 Sinatra API 调用,它将触发子进程中的长时间运行操作。我正在使用exception_handler gem,但不明白我将如何在分叉进程中使用它。
Sinatra 应用程序:
require 'sinatra'
require 'rubygems'
require 'bundler/setup'
require 'exception_notification'
use ExceptionNotification::Rack,
:email => {
:email_prefix => "[Example] ",
:sender_address => %{"notifier" <notifier@example.com>},
:exception_recipients => %w{me@example.com},
:delivery_method => :sendmail
}
get '/error' do
raise 'Bad!' # Notification gets sent
end
get '/error_async' do
p1 = fork do
sleep 10
raise 'Bad! (async)' # Notification never gets sent
end
Process.detach(p1)
end
【问题讨论】:
标签: ruby exception-handling sinatra fork