-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
logging.ini
for custom logger setup
- Loading branch information
1 parent
174c1c0
commit 7b1ea5e
Showing
7 changed files
with
28 additions
and
10 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 |
---|---|---|
|
@@ -11,3 +11,8 @@ PyNinja.egg-info/ | |
doc_gen/_* | ||
|
||
temp.py | ||
|
||
# work in progress | ||
samples/ | ||
logging.ini | ||
*.log |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,34 @@ | ||
import os | ||
import platform | ||
|
||
import uvicorn | ||
from fastapi import FastAPI | ||
|
||
from pyninja import routers, squire | ||
|
||
version = "0.0.0" | ||
|
||
|
||
def start(env_file: str = None) -> None: | ||
"""Starter function for the API, which uses uvicorn server as trigger.""" | ||
"""Starter function for the API, which uses uvicorn server as trigger. | ||
Args: | ||
env_file: Filepath for the ``.env`` file. | ||
""" | ||
squire.env = squire.env_loader( | ||
env_file or os.environ.get("env_file") or os.environ.get("ENV_FILE") or ".env" | ||
) | ||
app = FastAPI( | ||
routes=routers.routes, | ||
title=f"Service monitor for {platform.uname().node}", | ||
title="PyNinja", | ||
description="Light weight OS agnostic service monitoring API", | ||
version=version, | ||
) | ||
uvicorn.run( | ||
kwargs = dict( | ||
host=squire.env.ninja_host, | ||
port=squire.env.ninja_port, | ||
workers=squire.env.workers, | ||
app=app, | ||
) | ||
if os.path.isfile("logging.ini"): | ||
kwargs["log_config"] = os.path.join(os.getcwd(), "logging.ini") | ||
uvicorn.run(**kwargs) |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
VERSION = "0.0.0" |