Explorar o código

add logging to understand some crashes appearing in the logs

Rodja Trappe hai 1 ano
pai
achega
5e407091d8
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      website/fly.py

+ 8 - 1
website/fly.py

@@ -1,3 +1,4 @@
+import logging
 import os
 from urllib.parse import parse_qs
 
@@ -43,7 +44,13 @@ def setup() -> bool:
                         message['headers'] = []
                     message['headers'].append([b'fly-replay', f'instance={target_instance}'.encode()])
                 await send(message)
-            await self.app(scope, receive, send_wrapper)
+            try:
+                await self.app(scope, receive, send_wrapper)
+            except RuntimeError as e:
+                if 'No response returned.' in str(e):
+                    logging.warning(f'no response returned for {scope["path"]}')
+                else:
+                    logging.exception('could not handle request')
 
         def is_online(self, fly_instance_id: str) -> bool:
             hostname = f'{fly_instance_id}.vm.{self.app_name}.internal'