Skip to content

Commit

Permalink
Initialize domain before starting engine
Browse files Browse the repository at this point in the history
  • Loading branch information
subhashb committed Aug 11, 2024
1 parent 97a2dde commit 81faef6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/protean/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from protean.cli.new import new
from protean.cli.shell import shell
from protean.exceptions import NoDomainException
from protean.server.engine import Engine
from protean.utils.domain_discovery import derive_domain

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -155,7 +156,11 @@ def server(
logger.error(f"Error loading Protean domain: {exc.args[0]}")
raise typer.Abort()

from protean.server import Engine
# Traverse and initialize domain
# This will load all aggregates, entities, services, and other domain elements.
#
# By the time the handlers are invoked, the domain is fully initialized and ready to serve requests.
domain.init()

Check warning on line 163 in src/protean/cli/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/protean/cli/__init__.py#L163

Added line #L163 was not covered by tests

engine = Engine(domain, test_mode=test_mode, debug=debug)
engine.run()
Expand Down
2 changes: 1 addition & 1 deletion src/protean/server/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ async def shutdown(self, signal=None, exit_code=0):

try:
msg = (
"Received exit signal {signal.name}. Shutting down..."
f"Received exit signal {signal.name}. Shutting down..."
if signal
else "Shutting down..."
)
Expand Down

0 comments on commit 81faef6

Please sign in to comment.