Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run webserver with gunicorn #389

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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