import logging
import platform
import click

from biolib.biolib_logging import logger, logger_no_user_data


@click.command(help='Start a local compute node')
@click.option('--host', default='127.0.0.1', required=False)  # TODO: Validate host
@click.option('--port', default=5000, type=click.IntRange(1, 65_535), required=False)
def start(host: str, port: int) -> None:
    logger.configure(default_log_level=logging.INFO)
    logger_no_user_data.configure(default_log_level=logging.INFO)
    if platform.system() == 'Windows':
        raise Exception('Starting a compute node is currently not supported on Windows')

    from biolib.compute_node.webserver import webserver  # pylint: disable=import-outside-toplevel
    webserver.start_webserver(host=host, port=port)
