diff --git a/sgx-bwmsgsv2.rb b/sgx-bwmsgsv2.rb index 83d0181a459cc11c4f87c5781e027be1962479d6..d321b38f06b989faffa2ed138cf486d322c920dd 100755 --- a/sgx-bwmsgsv2.rb +++ b/sgx-bwmsgsv2.rb @@ -162,15 +162,17 @@ MMS_MIME_TYPES = [ MAX_MEDIA_SIZE = 1000000 def panic(e) - if e.is_a?(Exception) - Sentry.capture_exception(e, hint: { background: false }) - else - Sentry.capture_message(e.to_s, hint: { background: false }) - end - LOG.fatal("Shutting down gateway", e) - SGXbwmsgsv2.shutdown - LOG.info "Gateway has terminated" - EM.stop + EMPromise.resolve(nil).then { + if e.is_a?(Exception) + Sentry.capture_exception(e, hint: { background: false }) + else + Sentry.capture_message(e.to_s, hint: { background: false }) + end + LOG.fatal("Shutting down gateway", e) + SGXbwmsgsv2.shutdown + LOG.info "Gateway has terminated" + EM.stop + } end EM.error_handler(&method(:panic))