Skip to content

Commit

Permalink
Run webserver with gunicorn
Browse files Browse the repository at this point in the history
  • Loading branch information
rebkwok committed Jan 8, 2024
1 parent 3fb8a07 commit 90e5c04
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bot: python -m ebmbot.bot
dispatcher: python -m ebmbot.dispatcher
web: python -m ebmbot.webserver
web: gunicorn --config /app/gunicorn/conf.py ebmbot.webserver:app
release: rm -f /storage/.bot_startup_check
2 changes: 1 addition & 1 deletion docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ services:
extends:
service: dev
container_name: bennettbot-webserver
command: python -m ebmbot.webserver
command: gunicorn --config /app/gunicorn/conf.py ebmbot.webserver:app
# host:container ports: container port should match the port in WEBHOOK_ORIGIN
ports:
- "1234:1234"
Expand Down
7 changes: 4 additions & 3 deletions ebmbot/webserver/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from . import app


logger.info("running ebmbot.webserver")
port = urlparse(settings.WEBHOOK_ORIGIN).port
app.run(host="0.0.0.0", port=port, load_dotenv=False, debug=False)
if __name__ == "__main__":
logger.info("running ebmbot.webserver")
port = urlparse(settings.WEBHOOK_ORIGIN).port
app.run(host="0.0.0.0", port=port, load_dotenv=False, debug=False)
17 changes: 17 additions & 0 deletions gunicorn/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from urllib.parse import urlparse

from ebmbot import settings
from ebmbot.logger import logger


logger.info("running ebmbot.webserver")
port = urlparse(settings.WEBHOOK_ORIGIN).port

bind = f"0.0.0.0:{port}"

workers = 8
timeout = 120

# Where to log to (stdout and stderr)
accesslog = "-"
errorlog = "-"
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ extend-ignore = [
[tool.ruff.isort]
lines-after-imports = 2

[tool.ruff.per-file-ignores]
"gunicorn/conf.py" = ["INP001"]

[tool.pytest.ini_options]
env = [
"DB_PATH=tests/ebmbot.db",
Expand Down

0 comments on commit 90e5c04

Please sign in to comment.