1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00
This commit is contained in:
Steffo 2019-11-05 15:25:46 +01:00
parent c2d9f747fa
commit 933594b059
3 changed files with 8 additions and 5 deletions

View file

@ -15,6 +15,8 @@ import logging
help="Enable/disable the Discord bot.") help="Enable/disable the Discord bot.")
@click.option("--webserver/--no-webserver", default=None, @click.option("--webserver/--no-webserver", default=None,
help="Enable/disable the Web server.") help="Enable/disable the Web server.")
@click.option("--webserver-port", default=8001,
help="The port on which the web server will listen on.")
@click.option("-d", "--database", type=str, default=None, @click.option("-d", "--database", type=str, default=None,
help="The PostgreSQL database path.") help="The PostgreSQL database path.")
@click.option("-p", "--packs", type=str, multiple=True, default=[], @click.option("-p", "--packs", type=str, multiple=True, default=[],
@ -30,6 +32,7 @@ import logging
def run(telegram: typing.Optional[bool], def run(telegram: typing.Optional[bool],
discord: typing.Optional[bool], discord: typing.Optional[bool],
webserver: typing.Optional[bool], webserver: typing.Optional[bool],
webserver_port: typing.Optional[int],
database: typing.Optional[str], database: typing.Optional[str],
packs: typing.Tuple[str], packs: typing.Tuple[str],
network_address: typing.Optional[str], network_address: typing.Optional[str],
@ -169,7 +172,7 @@ def run(telegram: typing.Optional[bool],
tables=constellation_tables) tables=constellation_tables)
webserver_process = multiprocessing.Process(name="Constellation Webserver", webserver_process = multiprocessing.Process(name="Constellation Webserver",
target=constellation.run_blocking, target=constellation.run_blocking,
args=(verbose,), args=("0.0.0.0", webserver_port, verbose,),
daemon=True) daemon=True)
webserver_process.start() webserver_process.start()

View file

@ -1,4 +1,4 @@
semantic = "5.0a84" semantic = "5.0a85"
if __name__ == "__main__": if __name__ == "__main__":
print(semantic) print(semantic)

View file

@ -79,7 +79,7 @@ class Constellation:
def set_secret(self, username: str, password: str): def set_secret(self, username: str, password: str):
return keyring.set_password(f"Royalnet/{self.secrets_name}", username, password) return keyring.set_password(f"Royalnet/{self.secrets_name}", username, password)
def run_blocking(self, verbose): def run_blocking(self, address: str, port: int, verbose: bool):
if verbose: if verbose:
core_logger = logging.root core_logger = logging.root
core_logger.setLevel(logging.DEBUG) core_logger.setLevel(logging.DEBUG)
@ -88,5 +88,5 @@ class Constellation:
core_logger.addHandler(stream_handler) core_logger.addHandler(stream_handler)
core_logger.debug("Logging setup complete.") core_logger.debug("Logging setup complete.")
self._init_sentry() self._init_sentry()
log.info("Running constellation server...") log.info(f"Running constellation server on {address}:{port}...")
uvicorn.run(self.starlette) uvicorn.run(self.starlette, host=address, port=port)