Message ID | 20200601165023.GA500907@tsubame.mg0.fr |
---|---|
State | New |
Headers | show |
Series | [v2,1/2] aurweb.spawn: Integrate FastAPI and nginx | expand |
On Mon, 01 Jun 2020 at 12:50:23, Frédéric Mangano-Tarumi wrote: > conf/config.dev\u2019s purpose is to provide a lighter configuration template > for developers, and split development-specific options off the default > configuration file. > --- > TESTING | 8 +++----- > conf/config.defaults | 10 ---------- > conf/config.dev | 36 ++++++++++++++++++++++++++++++++++++ > 3 files changed, 39 insertions(+), 15 deletions(-) > create mode 100644 conf/config.dev Great, thanks! A few remarks below. > diff --git a/conf/config.dev b/conf/config.dev > new file mode 100644 > index 00000000..e9c2112e > --- /dev/null > +++ b/conf/config.dev > @@ -0,0 +1,36 @@ > +; Configuration file for aurweb development. > +; > +; Options are implicitly inherited from ${AUR_CONFIG}.defaults, which lists all Saying ${AUR_CONFIG}.defaults here is elegant, short, precise and clear to everybody who is familiar with the code base. However, given that those comments are mainly relevant to new contributors setting up a dev environment, I am not sure whether mentioning $AUR_CONFIG is a good idea here (people might not be aware of what exactly it is used for at this point). How about just saying config.defaults, given that the file is in the same directory? While being less precise, most people should still understand which file is referred to. > +; available options for productions, and their default values. This current file > +; overrides only options useful for development, and introduces > +; development-specific options too. > +; > +; Paths need to be absolute, so please replace $AUR_ROOT with your project root. Even though you added a comment is here, I am not sure that using $AUR_ROOT below is a great idea since it is too easy to skip part of the comment and then think that $AUR_ROOT is an actual placeholder parsed by aurweb. I would either go back to putting a sensible default path everywhere or replicate this comment directly above all lines containing $AUR_ROOT. > + > +[database] > + Stray newline? > +backend = sqlite > +name = $AUR_ROOT/aurweb.sqlite3 > + > +; Alternative MySQL configuration > +;backend = mysql > +;name = aurweb > +;user = aur > +;password = aur > + > +[options] > +aur_location = http://127.0.0.1:8080 > +disable_http_login = 0 > +enable-maintenance = 0 > + > +[php] > +; Address PHP should bind when spawned in development mode by aurweb.spawn. > +bind_address = 127.0.0.1:8081 > +; Directory containing aurweb's PHP code, required by aurweb.spawn. > +htmldir = $AUR_ROOT/web/html > + > +[fastapi] > +; Address uvicorn should bind when spawned in development mode by aurweb.spawn. > +bind_address = 127.0.0.1:8082 > + > +; vim: ft=dosini I think we usually don't add modelines or any other editor-specific configuration.
Lukas Fleischer [2020-06-01 21:05:57 -0400] > On Mon, 01 Jun 2020 at 12:50:23, Frédéric Mangano-Tarumi wrote: > > diff --git a/conf/config.dev b/conf/config.dev > > new file mode 100644 > > index 00000000..e9c2112e > > --- /dev/null > > +++ b/conf/config.dev > > @@ -0,0 +1,36 @@ > > +; Configuration file for aurweb development. > > +; > > +; Options are implicitly inherited from ${AUR_CONFIG}.defaults, which lists all > > Saying ${AUR_CONFIG}.defaults here is elegant, short, precise and clear > to everybody who is familiar with the code base. However, given that > those comments are mainly relevant to new contributors setting up a dev > environment, I am not sure whether mentioning $AUR_CONFIG is a good idea > here (people might not be aware of what exactly it is used for at this > point). How about just saying config.defaults, given that the file is in > the same directory? While being less precise, most people should still > understand which file is referred to. Developers need to set AUR_CONFIG to spawn aurweb. If we introduced it earlier like “Define the path to you configuration: export AUR_CONFIG="…"”, I think it should fit. As you implied though, using anything other than conf/config is madness. How about making aurweb.spawn set AUR_CONFIG to, by order of preference: 1. $AUR_CONFIG, if already defined, 2. $PWD/conf/config, if it exists, 3. $parent/conf/config where $parent is the nearest parent directory such that the file exists. aurweb.spawn is only meant for development, and it spawns test servers, so I think it makes sense to use a different default for AUR_CONFIG than production. > > +; available options for productions, and their default values. This current file > > +; overrides only options useful for development, and introduces > > +; development-specific options too. > > +; > > +; Paths need to be absolute, so please replace $AUR_ROOT with your project root. > > Even though you added a comment is here, I am not sure that using > $AUR_ROOT below is a great idea since it is too easy to skip part of the > comment and then think that $AUR_ROOT is an actual placeholder parsed by > aurweb. I would either go back to putting a sensible default path > everywhere or replicate this comment directly above all lines containing > $AUR_ROOT. I considered using relative paths, but because PHP changes the working directory and Python doesn’t, that can’t work. Nor can we have a sensible absolute path for everyone, since we cannot tell where the developer cloned the project. I can replace $AUR_ROOT by YOUR_AUR_ROOT, which is more explicit, and remove the comment. In TESTING, we can suggest using the following command: sed -e "s;YOUR_AUR_ROOT;$PWD;g" conf/config.dev > conf/config With more motivation, we could add support for environment variable interpolation in INI files. aurweb.config would know AUR_ROOT as a by-product of finding AUR_CONFIG, if we implement that. > > + > > +[database] > > + > > Stray newline? > > > +backend = sqlite > > +name = $AUR_ROOT/aurweb.sqlite3 > > + > > +; Alternative MySQL configuration > > +;backend = mysql > > +;name = aurweb > > +;user = aur > > +;password = aur I meant it to make the SQLite block stand out next to MySQL, but it does look special compared to other sections. In config.defaults, we use newlines only between sections, but that doesn’t leave much room for documentation. Interleaving comments with variables like I did below is okay only because the section is tiny. If the file grew bigger, I wish the norm was “block of documentation + set of correlated variable definitions + new line”. Sections would need a special comment to make them visible, like a ruler or a frame. > > +[php] > > +; Address PHP should bind when spawned in development mode by aurweb.spawn. > > +bind_address = 127.0.0.1:8081 > > +; Directory containing aurweb's PHP code, required by aurweb.spawn. > > +htmldir = $AUR_ROOT/web/html > > +; vim: ft=dosini > > I think we usually don't add modelines or any other editor-specific > configuration. Ok!
On Tue, 02 Jun 2020 at 08:41:28, Frédéric Mangano-Tarumi wrote: > > Saying ${AUR_CONFIG}.defaults here is elegant, short, precise and clear > > to everybody who is familiar with the code base. However, given that > > those comments are mainly relevant to new contributors setting up a dev > > environment, I am not sure whether mentioning $AUR_CONFIG is a good idea > > here (people might not be aware of what exactly it is used for at this > > point). How about just saying config.defaults, given that the file is in > > the same directory? While being less precise, most people should still > > understand which file is referred to. > > Developers need to set AUR_CONFIG to spawn aurweb. If we introduced it > earlier like \u201cDefine the path to you configuration: > export AUR_CONFIG="\u2026"\u201d, I think it should fit. That's better, even though I still don't believe it's more useful than just saying, config.defaults here. New users might set things up, then go back to the config the next day without knowing about $AUR_CONFIG anymore. > As you implied though, using anything other than conf/config is madness. > How about making aurweb.spawn set AUR_CONFIG to, by order of preference: > > 1. $AUR_CONFIG, if already defined, > 2. $PWD/conf/config, if it exists, > 3. $parent/conf/config where $parent is the nearest parent directory > such that the file exists. > > aurweb.spawn is only meant for development, and it spawns test servers, > so I think it makes sense to use a different default for AUR_CONFIG than > production. Sounds reasonable. I would prefer to infer the path from the location of the script itself (__file__) instead of (2) and (3) though. > I can replace $AUR_ROOT by YOUR_AUR_ROOT, which is more explicit, and > remove the comment. In TESTING, we can suggest using the following > command: > sed -e "s;YOUR_AUR_ROOT;$PWD;g" conf/config.dev > conf/config Sounds good. > With more motivation, we could add support for environment variable > interpolation in INI\u202ffiles. aurweb.config would know AUR_ROOT as a > by-product of finding AUR_CONFIG, if we implement that. Yeah, probably not worthwhile for just this one use case but something we might want to look into in the future. I am not sure what "aurweb.config would know AUR_ROOT as a by-product of finding AUR_CONFIG" means exactly but note that AUR_CONFIG is usually not contained in the document root in production setups. > I meant it to make the SQLite block stand out next to MySQL, but it does > look special compared to other sections. > > In config.defaults, we use newlines only between sections, but that > doesn\u2019t leave much room for documentation. Interleaving comments with > variables like I did below is okay only because the section is tiny. If > the file grew bigger, I wish the norm was \u201cblock of documentation + set > of correlated variable definitions + new line\u201d. Sections would need a > special comment to make them visible, like a ruler or a frame. I would hope that each section would correspond to exactly one set of correlated variable definitions, so we would not need this. I am aware that that's currently not the case though. > > I think we usually don't add modelines or any other editor-specific > > configuration. > > Ok! Thanks!
Lukas Fleischer [2020-06-02 17:40:23 -0400] > On Tue, 02 Jun 2020 at 08:41:28, Frédéric Mangano-Tarumi wrote: > > Developers need to set AUR_CONFIG to spawn aurweb. If we introduced it > > earlier like \u201cDefine the path to you configuration: > > export AUR_CONFIG="\u2026"\u201d, I think it should fit. > > That's better, even though I still don't believe it's more useful than > just saying, config.defaults here. New users might set things up, then > go back to the config the next day without knowing about $AUR_CONFIG > anymore. Saying config.defaults makes it look like it’s hard-coded, without further help. However, I agree with you it’s the simplest option. I’d add an extra “See aurweb/config.py for details.” if you don’t mind. > > As you implied though, using anything other than conf/config is madness. > > How about making aurweb.spawn set AUR_CONFIG to, by order of preference: > > > > 1. $AUR_CONFIG, if already defined, > > 2. $PWD/conf/config, if it exists, > > 3. $parent/conf/config where $parent is the nearest parent directory > > such that the file exists. > > Sounds reasonable. I would prefer to infer the path from the location of > the script itself (__file__) instead of (2) and (3) though. I’m not sure about __file__ because it gets complicated if the package is installed in a venv or something. We won’t implement that now anyway, so let’s talk about it another day. Same for AUR_ROOT. > > In config.defaults, we use newlines only between sections, but that > > doesn\u2019t leave much room for documentation. Interleaving comments with > > variables like I did below is okay only because the section is tiny. If > > the file grew bigger, I wish the norm was \u201cblock of documentation + set > > of correlated variable definitions + new line\u201d. Sections would need a > > special comment to make them visible, like a ruler or a frame. > > I would hope that each section would correspond to exactly one set of > correlated variable definitions, so we would not need this. I am aware > that that's currently not the case though. Actually I meant a stronger correlation, like variables that share the same documentation because that would make no sense to document them individually. See /etc/php/php.ini for the kind of layout I had in mind. There’s an empty line between every variable, and the file would be unreadable without it. I’ll apply that style but feel free to drop the empty lines from my patch without notice if you don’t like them.
diff --git a/TESTING b/TESTING index 31e3bcbd..f62baefa 100644 --- a/TESTING +++ b/TESTING @@ -17,12 +17,10 @@ INSTALL. Ensure to enable the pdo_sqlite extension in php.ini. -3) Copy conf/config.defaults to conf/config and adjust the configuration - Pay attention to disable_http_login, enable_maintenance, aur_location and - htmldir. +3) Copy conf/config.dev to conf/config and read its instructions. - Be sure to change backend to sqlite and name to the file location of your - created test database. + Note that when the upstream config.dev is updated, you should compare it to + your conf/config. 4) Prepare the testing database: diff --git a/conf/config.defaults b/conf/config.defaults index ed495168..447dacac 100644 --- a/conf/config.defaults +++ b/conf/config.defaults @@ -41,16 +41,6 @@ cache = none cache_pkginfo_ttl = 86400 memcache_servers = 127.0.0.1:11211 -[php] -; Address PHP should bind when spawned in development mode by aurweb.spawn. -bind_address = 127.0.0.1:8081 -; Directory containing aurweb's PHP code, required by aurweb.spawn. -;htmldir = /path/to/web/html - -[fastapi] -; Address uvicorn should bind when spawned in development mode by aurweb.spawn. -bind_address = 127.0.0.1:8082 - [ratelimit] request_limit = 4000 window_length = 86400 diff --git a/conf/config.dev b/conf/config.dev new file mode 100644 index 00000000..e9c2112e --- /dev/null +++ b/conf/config.dev @@ -0,0 +1,36 @@ +; Configuration file for aurweb development. +; +; Options are implicitly inherited from ${AUR_CONFIG}.defaults, which lists all +; available options for productions, and their default values. This current file +; overrides only options useful for development, and introduces +; development-specific options too. +; +; Paths need to be absolute, so please replace $AUR_ROOT with your project root. + +[database] + +backend = sqlite +name = $AUR_ROOT/aurweb.sqlite3 + +; Alternative MySQL configuration +;backend = mysql +;name = aurweb +;user = aur +;password = aur + +[options] +aur_location = http://127.0.0.1:8080 +disable_http_login = 0 +enable-maintenance = 0 + +[php] +; Address PHP should bind when spawned in development mode by aurweb.spawn. +bind_address = 127.0.0.1:8081 +; Directory containing aurweb's PHP code, required by aurweb.spawn. +htmldir = $AUR_ROOT/web/html + +[fastapi] +; Address uvicorn should bind when spawned in development mode by aurweb.spawn. +bind_address = 127.0.0.1:8082 + +; vim: ft=dosini