这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@loorisr
Copy link
Contributor

@loorisr loorisr commented Apr 6, 2025

What does this PR do?

This PR replace uWSGI with granian.

It is a Proof of Concept, it works but Granian configuration has to be tuned correctly.
Also all uWSGI files need to be cleaned (uwsgi.ini as well as docker entrypoint)

Why is this change important?

uWSGI is in bug fix only. A more modern solution should be used.

The project is in maintenance mode (only bugfixes and updates for new languages apis). Do not expect quick answers on github issues and/or pull requests (sorry for that) A big thanks to all of the users and contributors since 2009.

Related issues

#4479

@loorisr loorisr changed the title Granian [PoC] Granian Apr 6, 2025
@Bnyro
Copy link
Member

Bnyro commented Apr 6, 2025

uWSGI is not maintained any more.

Source? Their git repo seems to be very active.

Apparently it doesn't push new large features anymore, but why should it if it works perfectly fine with all its features now? ...

Copy link
Member

@Bnyro Bnyro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please convert the PR to a draft for now.

@loorisr
Copy link
Contributor Author

loorisr commented Apr 6, 2025

uWSGI is not maintained any more.

Source? Their git repo seems to be very active.

Sorry I will modify by "bugfix only", according to their website: https://uwsgi-docs.readthedocs.io/

The project is in maintenance mode (only bugfixes and updates for new languages apis). Do not expect quick answers on github issues and/or pull requests (sorry for that) A big thanks to all of the users and contributors since 2009.

@loorisr loorisr marked this pull request as draft April 6, 2025 09:56
printf 'Listen on %s\n' "${BIND_ADDRESS}"
exec uwsgi --master --uid searxng --gid searxng --http-socket "${BIND_ADDRESS}" "${UWSGI_SETTINGS_PATH}"
#exec uwsgi --master --uid searxng --gid searxng --http-socket "${BIND_ADDRESS}" "${UWSGI_SETTINGS_PATH}"
exec granian --interface wsgi searx.webapp:app --workers 3 --host 0.0.0.0 --port 8080
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Granian doesn't support config files, we would also need to port all the config here: https://github.com/searxng/searxng/blob/master/dockerfiles/uwsgi.ini to CLI arguments

@Bnyro
Copy link
Member

Bnyro commented Apr 6, 2025

I personally think it's generally a good idea to move away from Uwsgi and Granian looks like a good choice, however it's crucial that it still remains possible to run SearXNG with other wsgis (if not used via docker) so that we don't break existing installations.

@inetol
Copy link
Member

inetol commented Apr 6, 2025

Lack of config files is kind of a problem, as this PR seems to be focused on just Docker I'm going to pretend that everyone hasn't done weird hacks to run other WSGI servers with the default container image.

I've thought about allowing configuration through the CMD keyword in the Dockerfile itself, and then having the script passthrough all the parameters to granian. This would allow the default values to be easily modified if necessary.

@loorisr
Copy link
Contributor Author

loorisr commented Apr 6, 2025

On docker, we have docker-entrypoint.sh that calls granian so we could keep a config file if needed and the entrypoint call granian with the arguments from the config file?

@inetol
Copy link
Member

inetol commented Apr 6, 2025

I would prefer not to create new abstractions to configure other programs. I don't mind configuring granian with flags (as long as they are not hardcoded), but if really necessary, we could request a new feature for config file support.

@dalf
Copy link
Contributor

dalf commented Apr 6, 2025

The current docker image is built for linux/arm/v7 (Raspberry Pi 3 and some other SBC). Granian does not have wheels for arm/v7. We need to

  • either compile Granian for this architecture in the docker image (cumbersome and slow)
  • or make a PR to Granian to support this architecture, if this is okay. I'm not sure how (messense/manylinux_2_24-cross does not support armv7).
  • or stop support for this architecture.

[EDIT] no more relevant: there are now wheels for armv7

@return42
Copy link
Member

return42 commented Apr 6, 2025

Granian does not have wheels for arm/v7. We need to

@gi0baro do you see a chance to support wheels for arm/v7 in Granian?

@gi0baro
Copy link

gi0baro commented Apr 6, 2025

Granian does not have wheels for arm/v7. We need to

@gi0baro do you see a chance to support wheels for arm/v7 in Granian?

I see the maturin action supports armv7l, I can try to add that to the build process. A couple of very big unknowns though:

  • I have no idea if armv7l covers all your cases
  • I have no idea how Granian behaves on 32bit architectures

In addition, I have no access to such kind of hardware to actually test the builds, so even if a build step can be added and it actually compiles, sounds quite far from "supporting armv7" tbh.
If any of you have access to such kind of hardware, we might try to coordinate some tests in this regard.

@return42
Copy link
Member

return42 commented Apr 6, 2025

Apparently it doesn't push new large features anymore, but why should it if it works perfectly fine with all its features now? ...

🤔

.. the software is not in a state where everything works fine, one example can be found in Pitfalls of the Tyrant mode .. and what distributors do with uWSGI is little mess / distributors have their own concepts .. see: Distributors

If we get rid of "Distributor's concepts" and install (with Granain) directly from PyPi, I think the setup would be much easier.

All in all, with uWSGI we have a poorly maintained product that will not be improved any further and that has to be set up on the various distros in different ways. On the other hand, with Granian we have a product that is actively maintained and the maintainer (thanks goes to @gi0baro) who is already actively supporting us here in our thread :-)

@gi0baro
Copy link

gi0baro commented Apr 6, 2025

Out of curiosity, I successfully run a build workflow with armv7 builds here https://github.com/emmett-framework/granian/actions/runs/14295016210

Again, I have no idea if those wheels actually work.

@dalf
Copy link
Contributor

dalf commented Apr 9, 2025

There are now (experimental) wheels for armv7, thank you @gi0baro : https://github.com/emmett-framework/granian/releases/tag/v2.2.3

@inetol
Copy link
Member

inetol commented Apr 10, 2025

I have done a production deploy with this change on https://search.inetol.net instance to pick up performance telemetry and properly configure granian. All the errors that are coming out will be published on https://github.com/inetol-infrastructure/searxng-container/issues to avoid polluting this PR.

@loorisr
Copy link
Contributor Author

loorisr commented Apr 11, 2025

I have done a production deploy with this change on https://search.inetol.net instance to pick up performance telemetry and properly configure granian. All the errors that are coming out will be published on https://github.com/inetol-infrastructure/searxng-container/issues to avoid polluting this PR.

are you using arm/v7 on the host?

@inetol
Copy link
Member

inetol commented Apr 11, 2025

are you using arm/v7 on the host?

No, only x86. I'm not building the images for arm/v7 there, as I don't have the hardware to test it.

@return42
Copy link
Member

return42 commented Apr 11, 2025

are you using arm/v7 on the host?

The test of @inetol should be limited to the SearXNG's migration from uWSGI to Granian ... a functional test of Granian on 32bit should be done by someone else (not really in the scope of the SearXNG project) .. a 32bit hardware is not required for this, it can be emulated with Qemu on a 64bit architecture (Pi2 Model has a Cortex-A7 CPU).

@inetol
Copy link
Member

inetol commented Apr 26, 2025

There don't seem to be any other problems with Granian apart from the issue with static files. Obviously, this PR needs to be updated with the Granian env settings from my repo.

As I'm using a somewhat tight SXNG settings there might be something I missed, so if anyone wants to quickly spin up a new instance for testing this I'm now publishing the container images to the registry.

@return42 return42 added the armv7 label Apr 27, 2025
@inetol inetol mentioned this pull request May 1, 2025
inetol added a commit to inetol/searxng that referenced this pull request Jun 3, 2025
The configuration in Granian is handled with ENVs, much more convenient and practical for updating. The settings have been tested for over two months in a production instance, being usable on small to somewhat large instances without having to modify anything.

It also removes the patch functions and ENVs abstraction from the entrypoint, this makes it possible to run the container with immutable configuration.

In some setups, It may be desired to have the volumes/files under a specific uid/gid (other than searxng:searxng), if the entrypoint has root permissions it will chown automatically on every start, which may not be desired. Explicitly setting the new ENV `FORCE_OWNERSHIP=false` will prevent ownership from being modified.

No manual migration is necessary unless the user has changed the default uWSGI configuration or has a very specific setup.

Closes searxng#4818

Supersedes searxng#4596

Related searxng#4479
inetol added a commit to inetol/searxng that referenced this pull request Jun 6, 2025
The configuration in Granian is handled with ENVs, much more convenient and practical for updating. The settings have been tested for over two months in a production instance, being usable on small to somewhat large instances without having to modify anything.

It also removes the patch functions and ENVs abstraction from the entrypoint, this makes it possible to run the container with immutable configuration.

In some setups, It may be desired to have the volumes/files under a specific uid/gid (other than searxng:searxng), if the entrypoint has root permissions it will chown automatically on every start, which may not be desired. Explicitly setting the new ENV `FORCE_OWNERSHIP=false` will prevent ownership from being modified.

No manual migration is necessary unless the user has changed the default uWSGI configuration or has a very specific setup.

Closes searxng#4818

Supersedes searxng#4596

Related searxng#4479
inetol added a commit to inetol/searxng that referenced this pull request Jun 6, 2025
…nt and practical for updating. The settings have been tested for over two months in a production instance, being usable on small to somewhat large instances without having to modify anything.

It also removes the patch functions and ENVs abstraction from the entrypoint, this makes it possible to run the container with immutable configuration.

In some setups, It may be desired to have the volumes/files under a specific uid/gid (other than searxng:searxng), if the entrypoint has root permissions it will chown automatically on every start, which may not be desired. Explicitly setting the new ENV `FORCE_OWNERSHIP=false` will prevent ownership from being modified.

Those changes are reflected in the documentation, which also received a rework.

No manual migration is necessary **unless** the user has changed the default uWSGI configuration or has a very specific setup.

Closes searxng#4894
Closes searxng#4818
Closes searxng#4802

Supersedes searxng#4596

Related searxng#4479
@Bnyro
Copy link
Member

Bnyro commented Jun 8, 2025

superseded by #4820

@Bnyro Bnyro closed this Jun 8, 2025
inetol added a commit to inetol/searxng that referenced this pull request Jun 11, 2025
The configuration in Granian is handled with ENVs, much more convenient and practical for updating. The settings have been tested for over two months in a production instance, being usable on small to somewhat large instances without having to modify anything.

It also removes the patch functions and ENVs abstraction from the entrypoint, this makes it possible to run the container with immutable configuration.

In some setups, It may be desired to have the volumes/files under a specific uid/gid (other than searxng:searxng), if the entrypoint has root permissions it will chown automatically on every start, which may not be desired. Explicitly setting the new ENV `FORCE_OWNERSHIP=false` will prevent ownership from being modified.

No manual migration is necessary **unless** the user has changed the default uWSGI configuration or has a very specific setup.

Closes searxng#4894
Closes searxng#4818
Closes searxng#4802

Supersedes searxng#4596

Related searxng#4479
inetol added a commit to inetol/searxng that referenced this pull request Jun 27, 2025
The configuration in Granian is handled with ENVs, much more convenient and practical for updating. The settings have been tested for over two months in a production instance, being usable on small to somewhat large instances without having to modify anything.

It also removes the patch functions and ENVs abstraction from the entrypoint, this makes it possible to run the container with immutable configuration.

In some setups, It may be desired to have the volumes/files under a specific uid/gid (other than searxng:searxng), if the entrypoint has root permissions it will chown automatically on every start, which may not be desired. Explicitly setting the new ENV `FORCE_OWNERSHIP=false` will prevent ownership from being modified.

No manual migration is necessary **unless** the user has changed the default uWSGI configuration or has a very specific setup.

Closes searxng#4894
Closes searxng#4818
Closes searxng#4802

Supersedes searxng#4596

Related searxng#4479
inetol added a commit to inetol/searxng that referenced this pull request Jun 28, 2025
The configuration in Granian is handled with ENVs, much more convenient and practical for updating. The settings have been tested for over two months in a production instance, being usable on small to somewhat large instances without having to modify anything.

It also removes the patch functions and ENVs abstraction from the entrypoint, this makes it possible to run the container with immutable configuration.

In some setups, It may be desired to have the volumes/files under a specific uid/gid (other than searxng:searxng), if the entrypoint has root permissions it will chown automatically on every start, which may not be desired. Explicitly setting the new ENV `FORCE_OWNERSHIP=false` will prevent ownership from being modified.

No manual migration is necessary **unless** the user has changed the default uWSGI configuration or has a very specific setup.

Closes searxng#4894
Closes searxng#4818
Closes searxng#4802

Supersedes searxng#4596

Related searxng#4479
inetol added a commit that referenced this pull request Jul 4, 2025
* [mod] container: replace uWSGI with Granian

The configuration in Granian is handled with ENVs, much more convenient and practical for updating. The settings have been tested for over two months in a production instance, being usable on small to somewhat large instances without having to modify anything.

It also removes the patch functions and ENVs abstraction from the entrypoint, this makes it possible to run the container with immutable configuration.

In some setups, It may be desired to have the volumes/files under a specific uid/gid (other than searxng:searxng), if the entrypoint has root permissions it will chown automatically on every start, which may not be desired. Explicitly setting the new ENV `FORCE_OWNERSHIP=false` will prevent ownership from being modified.

No manual migration is necessary **unless** the user has changed the default uWSGI configuration or has a very specific setup.

Closes #4894
Closes #4818
Closes #4802

Supersedes #4596

Related #4479

* [mod] docs: add container/granian

All container documentation has been recreated.

A new documentation page has been created for Granian.

* [enh] misc: apply suggestions

Minor documentation changes.

Suggested #4820 (comment)
Suggested #4820 (comment)
Suggested #4820 (comment)
Suggested #4820 (comment)
Suggested #4820 (comment)

---------

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Co-authored-by: Ivan Gabaldon <igabaldon@inetol.net>
Co-authored-by: Markus Heiser <markus.heiser@darmarit.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants