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

[runwsgi] Cannot override [DEFAULT] section entries from the command line #938

Open
dwt opened this issue Dec 11, 2020 · 2 comments
Open

Comments

@dwt
Copy link
Contributor

dwt commented Dec 11, 2020

What I did:

Given a zope config like this:

[DEFAULT]
http_port = 8000

[app:zope]
use = egg:Zope#main
zope_conf = %(here)s/zope.conf

[pipeline:main]
pipeline =
    egg:Zope#httpexceptions
    zope

[server:main]
use = egg:waitress#main
host = 127.0.0.1
port = %(http_port)s

I tried overriding that value from the command line by calling runwsgi like this

runwsgi --verbose --debug instances/test/etc/wsgi.ini http_port=8001

I expected the resulting server to run on port 8001 - but it didn't and instead ran on DEFAULT.http_port.

What I expect to happen:

There should be a way to verride values from the command line while allowing a default value from the configuration file.

What actually happened:

Overriding not possible.

What version of Python and Zope/Addons I am using:

% python --version                                                                                                                            :(
Python 3.6.8
% pip list |grep -i zope
Zope                             5.1.1.dev0 /Users/dwt/Code/Projekte/zope4/Zope/src
@icemac
Copy link
Member

icemac commented Dec 14, 2020

I am not sure if your expectation should be matched by a code change as it makes the code more complex for a use case which seems exotic to me. But let's see what others think.

@dwt
Copy link
Contributor Author

dwt commented Dec 14, 2020

Well, I would have expected that command-line values have more precedence than config file options.

For development at least I would like to quickly override a setting from the shell to test out the effect. Also something like this doesn't work: runwsgi --verbose --debug instances/test/etc/wsgi.ini server:main.port=8001 to force a different port.

The workaround I used is to have a non defaulted http_port variable in the config, that is then provided on the command line, but that means that one has to always provide it. That is easily worked around by a wrapper script which sets it if not provided - but it sucks.

I ran into this when I tried to run multiple workers for a zeo deployment and tried to instantiate them from a systemd template unit like this:

# {{ ansible_managed }}
[Unit]
Description=ZMS/Zope production environment
After=network-online.target
PartOf=zms-{{ zope_instance.name }}.target
After=zms-{{ zope_instance.name }}.target

[Service]
Type=simple
User=zope
Restart=always
Environment=HTTP_PORT=%i
ExecStart=/home/zope/instances/{{ zope_instance.name }}/bin/runzope

[Install]
WantedBy=zms-{{ zope_instance.name }}.target

This is then instantiated by enabling systemd services like this: `systemd enable --now zms-$instance_name.zope@{8001..8006}.service

Right now, this hands in the port via an environment variable and then calls a wrapper script that defaults that port to ensure that for debugging, the zope service can still be easily started on the default port manually. I thought it more intuitive if this was achievable by directly calling runwsgi for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants