-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: removes FastAPI server and improves logging
- Loading branch information
1 parent
42fd4b2
commit 5edb115
Showing
13 changed files
with
94 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.venv | ||
__pycache__ | ||
loader.py | ||
output.txt | ||
output.txt | ||
.embeddins_models_cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,41 @@ | ||
import sys | ||
import signal | ||
import logging | ||
|
||
from src.grpc.server import serve | ||
from src.utils import OramaAIConfig | ||
from src.models.main import ModelsManager | ||
from src.service.embedding import EmbeddingService | ||
|
||
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def handle_shutdown(signum, frame): | ||
print("\nShutting down gracefully...") | ||
logger.info("\nShutting down gracefully...") | ||
sys.exit(0) | ||
|
||
|
||
if __name__ == "__main__": | ||
signal.signal(signal.SIGINT, handle_shutdown) | ||
signal.signal(signal.SIGTERM, handle_shutdown) | ||
|
||
logger.info("Initializing config...") | ||
config = OramaAIConfig() | ||
|
||
logger.info("Initializing embedding service...") | ||
embeddings_service = EmbeddingService(config) | ||
|
||
logger.info("Initializing models manager...") | ||
models_manager = ModelsManager(config) | ||
|
||
try: | ||
logger.info(f"Starting gRPC server on port {config.grpc_port}...") | ||
serve(config, embeddings_service.embeddings_service, models_manager) | ||
except KeyboardInterrupt: | ||
print("\nShutting down gracefully...") | ||
logger.info("\nShutting down gracefully...") | ||
sys.exit(0) | ||
except Exception as e: | ||
logger.error(f"Error starting server: {e}", exc_info=True) | ||
sys.exit(1) |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.