-
Notifications
You must be signed in to change notification settings - Fork 508
[WIP] feat: replace uwsgi with granian #1321
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| {% include "build/openedx/settings/granian-config" %} | ||
| {{ patch("granian-config") }} |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| #! /bin/bash | ||
| echo "Reloading granian process..." | ||
| date +%s > /openedx/granian-reload-path |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #!/usr/bin/env python3 | ||
| import os | ||
| from granian.cli import cli | ||
|
|
||
|
|
||
| def parse_args_file() -> list[str]: | ||
| args = [] | ||
| with open("/openedx/granian-config") as f: | ||
| for line in f: | ||
| line = line.strip() | ||
| if not line or line.startswith("#"): | ||
| # skip empty lines and comments | ||
| continue | ||
|
|
||
| # Expand environment variables like $VAR_NAME | ||
| line = os.path.expandvars(line) | ||
|
|
||
| # Split by first space (for options with values) | ||
| if " " in line: | ||
| option, value = line.split(" ", 1) | ||
| args.append(option) | ||
| args.append(value) | ||
| else: | ||
| # flags without values | ||
| args.append(line) | ||
| return args | ||
|
|
||
|
|
||
| def run(): | ||
| cli(args=parse_args_file(), standalone_mode=False) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise, please comment what |
||
|
|
||
| if __name__ == "__main__": | ||
| run() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general, please add a trailing new line in your files. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --interface wsgi | ||
| --host 0.0.0.0 | ||
| --port 8000 | ||
| --workers $GRANIAN_WORKERS | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not blocking, but I'm curious if you folks are planning to experiment with different threading values? |
||
| --static-path-route /static | ||
| --static-path-mount /openedx/staticfiles/ | ||
| --static-path-route /media | ||
| --static-path-mount /openedx/media/ | ||
| --reload | ||
| --reload-paths /openedx/granian-reload-path | ||
|
Comment on lines
+9
to
+10
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is for watching a directory and reloading if there are file changes detected, right? Just out of curiosity, why enable this in a prod environment?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We had a |
||
| --http1-buffer-size 8192 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems really low? Is this because we're not actually expecting to get HTTP 1.1 requests? |
||
| $SERVICE_VARIANT.wsgi:application | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a docstring explaining why this is necessary (I realize it's because granian doesn't support a config file format, but this might be confusing to people who don't know that.)