i'm building sinatra api call trigger long-running operation in subprocess. i'm using exception_handler gem, don't understand how i'd use in forked process.
sinatra app:
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 } '/error' raise 'bad!' # notification gets sent end '/error_async' p1 = fork sleep 10 raise 'bad! (async)' # notification never gets sent end process.detach(p1) end
got working, per docs:
get '/error_async' p1 = fork begin sleep 10 raise 'bad! (async)' rescue exception => e exceptionnotifier.notify_exception(e) end end process.detach(p1) end
Comments
Post a Comment