2022-11-19 15:14:12 -08:00
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import typer
|
|
|
|
|
|
|
|
from dotenv import load_dotenv
|
2022-11-20 01:00:54 -08:00
|
|
|
|
2022-11-20 09:28:00 -08:00
|
|
|
from groove import webserver
|
|
|
|
from groove.db.manager import database_manager
|
2022-11-19 15:14:12 -08:00
|
|
|
|
|
|
|
|
|
|
|
app = typer.Typer()
|
|
|
|
|
|
|
|
|
2022-11-20 01:00:54 -08:00
|
|
|
def initialize():
|
|
|
|
load_dotenv()
|
2022-11-20 09:28:00 -08:00
|
|
|
debug = os.getenv('DEBUG', None)
|
|
|
|
logging.basicConfig(format='%(asctime)s - %(message)s',
|
|
|
|
level=logging.DEBUG if debug else logging.INFO)
|
2022-11-20 01:00:54 -08:00
|
|
|
|
|
|
|
|
2022-11-19 15:14:12 -08:00
|
|
|
@app.command()
|
|
|
|
def server(
|
|
|
|
host: str = typer.Argument(
|
|
|
|
'0.0.0.0',
|
|
|
|
help="bind address",
|
|
|
|
),
|
|
|
|
port: int = typer.Argument(
|
|
|
|
2323,
|
|
|
|
help="bind port",
|
|
|
|
),
|
|
|
|
debug: bool = typer.Option(
|
|
|
|
False,
|
|
|
|
help='Enable debugging output'
|
|
|
|
),
|
|
|
|
):
|
|
|
|
"""
|
|
|
|
Start the Groove on Demand playlsit server.
|
|
|
|
"""
|
|
|
|
print("Starting Groove On Demand...")
|
2022-11-20 09:28:00 -08:00
|
|
|
initialize()
|
|
|
|
with database_manager as manager:
|
|
|
|
manager.import_from_filesystem()
|
|
|
|
webserver.start(host=host, port=port, debug=debug)
|
2022-11-19 15:14:12 -08:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
app()
|