Skip to content

Commit

Permalink
fix double sanic logging, simplified ssl context setup, remove redis …
Browse files Browse the repository at this point in the history
…lock comment line
  • Loading branch information
Jan Safarik committed Nov 8, 2019
1 parent 13e66d6 commit 755ef54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
17 changes: 4 additions & 13 deletions rasa_sdk/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def endpoint_app(
action_package_name: Union[Text, types.ModuleType],
cors_origins: Union[Text, List[Text], None] = "*",
):
app = Sanic(__name__)
app = Sanic(__name__, configure_logging=False)

configure_cors(app, cors_origins)

Expand Down Expand Up @@ -145,19 +145,10 @@ def run(
ssl_password=None,
):
logger.info("Starting action endpoint server...")
app = endpoint_app(
action_package_name, cors_origins=cors_origins,
)
app = endpoint_app(action_package_name, cors_origins=cors_origins,)
ssl_context = create_ssl_context(ssl_certificate, ssl_keyfile, ssl_password)
protocol = "https" if ssl_context else "http"
host = "0.0.0.0"
if ssl_context:
app.run(host, port, ssl=ssl_context, workers=utils.number_of_sanic_workers())
else:
app.run(host, port, workers=utils.number_of_sanic_workers())
logger.info(
"Action endpoint is up and running on {} {}:{}".format(protocol, host, port)
)

app.run("0.0.0.0", port, ssl=ssl_context, workers=utils.number_of_sanic_workers())


if __name__ == "__main__":
Expand Down
4 changes: 1 addition & 3 deletions rasa_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ def arguments_of(func) -> List[Text]:

def number_of_sanic_workers() -> int:
"""Get the number of Sanic workers to use in `app.run()`.
If the environment variable constants.ENV_SANIC_WORKERS is set and is not equal to
1, that value will only be permitted if the used lock store supports shared
resources across multiple workers (e.g. ``RedisLockStore``).
If the environment variable constants.ENV_SANIC_WORKERS is set and is not equal to 1.
"""

def _log_and_get_default_number_of_workers():
Expand Down

0 comments on commit 755ef54

Please sign in to comment.