Skip to content

Process --enable-* flags before loading plugins #860

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

Merged
merged 3 commits into from
Dec 11, 2021
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: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ extend-ignore =
Q003 # FIXME: avoid escaping in-string quotes
RST201 # FIXME: missing trailing blank line in docstring
RST203 # FIXME: no trailing blank line in docstring
RST299 # FIXME: Cannot extract compound bibliographic field "copyright"
RST301 # FIXME: unexpected indent in docstring
RST499 # FIXME: Missing matching underline for section title overline
S101 # FIXME: assertions are thrown away in optimized mode, needs audit
S104 # FIXME: bind-all interface listen
S105 # FIXME: hardcoded password?
Expand Down
39 changes: 25 additions & 14 deletions proxy/common/flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,30 @@ def initialize(
# unless user overrides the default auth plugin.
auth_plugins.append(auth_plugin)

# --enable flags must be parsed before loading plugins
# otherwise we will miss the plugins passed via constructor
args.enable_web_server = cast(
bool,
opts.get(
'enable_web_server',
args.enable_web_server,
),
)
args.enable_static_server = cast(
bool,
opts.get(
'enable_static_server',
args.enable_static_server,
),
)
args.enable_events = cast(
bool,
opts.get(
'enable_events',
args.enable_events,
),
)

# Load default plugins along with user provided --plugins
default_plugins = [
bytes_(p)
Expand Down Expand Up @@ -290,20 +314,14 @@ def initialize(
args.num_acceptors = cast(
int, num_acceptors if num_acceptors > 0 else multiprocessing.cpu_count(),
)

args.static_server_dir = cast(
str,
opts.get(
'static_server_dir',
args.static_server_dir,
),
)
args.enable_static_server = cast(
bool,
opts.get(
'enable_static_server',
args.enable_static_server,
),
)
args.min_compression_limit = cast(
bool,
opts.get(
Expand All @@ -324,13 +342,6 @@ def initialize(
args.timeout = cast(int, opts.get('timeout', args.timeout))
args.threadless = cast(bool, opts.get('threadless', args.threadless))
args.threaded = cast(bool, opts.get('threaded', args.threaded))
args.enable_events = cast(
bool,
opts.get(
'enable_events',
args.enable_events,
),
)
args.pid_file = cast(
Optional[str], opts.get(
'pid_file',
Expand Down