Skip to content

Commit 6b6cd27

Browse files
authored
Debug Logging in Launch (#487)
1 parent cb51bbe commit 6b6cd27

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

dbos/_dbos.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ def _launch(self, *, debug_mode: bool = False) -> None:
452452
assert self._config["database"]["sys_db_engine_kwargs"] is not None
453453
# Get the schema configuration, use "dbos" as default
454454
schema = self._config.get("dbos_system_schema", "dbos")
455+
dbos_logger.debug("Creating system database")
455456
self._sys_db_field = SystemDatabase.create(
456457
system_database_url=get_system_database_url(self._config),
457458
engine_kwargs=self._config["database"]["sys_db_engine_kwargs"],
@@ -462,6 +463,7 @@ def _launch(self, *, debug_mode: bool = False) -> None:
462463
)
463464
assert self._config["database"]["db_engine_kwargs"] is not None
464465
if self._config["database_url"]:
466+
dbos_logger.debug("Creating application database")
465467
self._app_db_field = ApplicationDatabase.create(
466468
database_url=self._config["database_url"],
467469
engine_kwargs=self._config["database"]["db_engine_kwargs"],
@@ -474,8 +476,10 @@ def _launch(self, *, debug_mode: bool = False) -> None:
474476
return
475477

476478
# Run migrations for the system and application databases
479+
dbos_logger.debug("Running system database migrations")
477480
self._sys_db.run_migrations()
478481
if self._app_db:
482+
dbos_logger.debug("Running application database migrations")
479483
self._app_db.run_migrations()
480484

481485
admin_port = self._config.get("runtimeConfig", {}).get("admin_port")
@@ -486,10 +490,12 @@ def _launch(self, *, debug_mode: bool = False) -> None:
486490
)
487491
if run_admin_server:
488492
try:
493+
dbos_logger.debug("Starting admin server")
489494
self._admin_server_field = AdminServer(dbos=self, port=admin_port)
490495
except Exception as e:
491496
dbos_logger.warning(f"Failed to start admin server: {e}")
492497

498+
dbos_logger.debug("Retrieving local pending workflows for recovery")
493499
workflow_ids = self._sys_db.get_pending_workflows(
494500
GlobalParams.executor_id, GlobalParams.app_version
495501
)
@@ -505,6 +511,7 @@ def _launch(self, *, debug_mode: bool = False) -> None:
505511
self._executor.submit(startup_recovery_thread, self, workflow_ids)
506512

507513
# Listen to notifications
514+
dbos_logger.debug("Starting notifications listener thread")
508515
notification_listener_thread = threading.Thread(
509516
target=self._sys_db._notification_listener,
510517
daemon=True,
@@ -516,6 +523,7 @@ def _launch(self, *, debug_mode: bool = False) -> None:
516523
self._registry.get_internal_queue()
517524

518525
# Start the queue thread
526+
dbos_logger.debug("Starting queue thread")
519527
evt = threading.Event()
520528
self.background_thread_stop_events.append(evt)
521529
bg_queue_thread = threading.Thread(
@@ -531,6 +539,7 @@ def _launch(self, *, debug_mode: bool = False) -> None:
531539
self.conductor_url = f"wss://{dbos_domain}/conductor/v1alpha1"
532540
evt = threading.Event()
533541
self.background_thread_stop_events.append(evt)
542+
dbos_logger.debug("Starting Conductor thread")
534543
self.conductor_websocket = ConductorWebsocket(
535544
self,
536545
conductor_url=self.conductor_url,
@@ -541,6 +550,7 @@ def _launch(self, *, debug_mode: bool = False) -> None:
541550
self._background_threads.append(self.conductor_websocket)
542551

543552
# Grab any pollers that were deferred and start them
553+
dbos_logger.debug("Starting event receivers")
544554
for evt, func, args, kwargs in self._registry.pollers:
545555
self.poller_stop_events.append(evt)
546556
poller_thread = threading.Thread(

0 commit comments

Comments
 (0)