MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / initialize

Function initialize

methods/MIRIX/mirix/server/rest_api.py:86–127  ·  view source on GitHub ↗

Initialize the Mirix server and queue services. This function can be called by external applications to initialize the server.

()

Source from the content-addressed store, hash-verified

84
85
86async def initialize():
87 """
88 Initialize the Mirix server and queue services.
89 This function can be called by external applications to initialize the server.
90 """
91 logger.info("Starting Mirix REST API server")
92
93 # Create database tables (async engine) before initializing server
94 await ensure_tables_created()
95
96 # Initialize Redis (async ping, create_indexes, log stats)
97 try:
98 from mirix.database.redis_client import get_redis_client
99
100 redis_client = get_redis_client()
101 if redis_client:
102 if await redis_client.ping():
103 await redis_client.create_indexes()
104 await redis_client.log_connection_stats()
105 logger.info("Redis async client ready")
106 else:
107 logger.warning("Redis ping failed - continuing without Redis")
108 except Exception as e:
109 logger.warning("Redis async init failed: %s", e)
110
111 # Initialize AsyncServer (singleton) and create default org/user/client
112 server = get_server()
113 await server.ensure_defaults()
114 logger.info("AsyncServer initialized")
115
116 # Initialize queue with server reference
117 await initialize_queue(server)
118 logger.info("Queue service started with AsyncServer integration")
119
120 # Initialize LangFuse observability (async)
121 try:
122 from mirix.observability import initialize_langfuse
123
124 logger.info("Initializing LangFuse observability...")
125 await initialize_langfuse()
126 except Exception as e:
127 logger.warning(f"LangFuse initialization failed: {e}. Continuing without observability.")
128
129
130async def cleanup():

Callers 1

lifespanFunction · 0.85

Calls 11

ensure_tables_createdFunction · 0.90
get_redis_clientFunction · 0.90
initialize_queueFunction · 0.90
initialize_langfuseFunction · 0.90
get_serverFunction · 0.85
create_indexesMethod · 0.80
log_connection_statsMethod · 0.80
ensure_defaultsMethod · 0.80
infoMethod · 0.65
pingMethod · 0.45
warningMethod · 0.45

Tested by

no test coverage detected