mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
use same logging infrastructure for uvicorn and backend
This commit is contained in:
parent
6f54fe9003
commit
c4a2808a4b
@ -3,6 +3,7 @@ import asyncio
|
|||||||
import sys
|
import sys
|
||||||
from inspect import signature
|
from inspect import signature
|
||||||
|
|
||||||
|
import logging
|
||||||
import uvicorn
|
import uvicorn
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
@ -210,11 +211,23 @@ def invoke_api():
|
|||||||
port = find_port(app_config.port)
|
port = find_port(app_config.port)
|
||||||
if port != app_config.port:
|
if port != app_config.port:
|
||||||
logger.warn(f"Port {app_config.port} in use, using port {port}")
|
logger.warn(f"Port {app_config.port} in use, using port {port}")
|
||||||
|
|
||||||
# Start our own event loop for eventing usage
|
# Start our own event loop for eventing usage
|
||||||
loop = asyncio.new_event_loop()
|
loop = asyncio.new_event_loop()
|
||||||
config = uvicorn.Config(app=app, host=app_config.host, port=port, loop=loop)
|
config = uvicorn.Config(
|
||||||
# Use access_log to turn off logging
|
app=app,
|
||||||
|
host=app_config.host,
|
||||||
|
port=port,
|
||||||
|
loop=loop,
|
||||||
|
log_level=app_config.log_level,
|
||||||
|
)
|
||||||
server = uvicorn.Server(config)
|
server = uvicorn.Server(config)
|
||||||
|
|
||||||
|
# replace uvicorn's logger with InvokeAI's for consistent appearance
|
||||||
|
logging.getLogger("uvicorn").handlers.clear()
|
||||||
|
for ch in logger.handlers:
|
||||||
|
logging.getLogger("uvicorn").addHandler(ch)
|
||||||
|
|
||||||
loop.run_until_complete(server.serve())
|
loop.run_until_complete(server.serve())
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user