backport: put a promise in that panic

Phillip Davis created

Change summary

sgx-bwmsgsv2.rb | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

Detailed changes

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))