Skip to content

Commit

Permalink
Only kill process on failed load if not live_reload (#166)
Browse files Browse the repository at this point in the history
don't kill the process when live reload is enabled
  • Loading branch information
zero1zero authored Dec 23, 2022
1 parent 4942088 commit 4cadc10
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions truss/templates/server/common/truss_server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json # noqa: E402
import logging # noqa: E402
import os
import sys
from http import HTTPStatus # noqa: E402
from threading import Thread
Expand Down Expand Up @@ -169,15 +170,18 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
_configure_logging()

def load_all(self, main_loop):
def load_all(self, main_loop: IOLoop):
try:
for model in self.registered_models.get_models():
model.load()
except Exception as e:
logging.error(f"Error loading model: {e}")
self._http_server.stop()
main_loop.stop()
sys.exit(1)

# fixme(zack) for live reload, we don't want to kill the process?
if not os.environ.get("CONTROL_SERVER_PORT"):
self._http_server.stop()
main_loop.stop()
sys.exit(1)

def start(self, models: List[KFModel], nest_asyncio: bool = False):
if len(models) != 1:
Expand Down

0 comments on commit 4cadc10

Please sign in to comment.