Commit Graph

61 Commits

Author SHA1 Message Date
zurdi
5d1114b832 refactor: set default web concurrency to reduce resource usage 2025-05-08 10:44:58 +00:00
zurdi
82c265e7d3 refactor: update log messages for consistency and clarity 2025-05-08 10:40:08 +00:00
zurdi
3bd9382b12 refactor: enable scheduled tasks in scheduler and init scripts 2025-05-08 08:59:56 +00:00
Michael Manganiello
9602d58865 misc: Add support for WEB_CONCURRENCY environment variable
The `WEB_CONCURRENCY` environment variable is a more common way to
configure the number of workers for Gunicorn [1] or other web servers.

This change maintains `GUNICORN_WORKERS` compatibility, while notifying
users that it is deprecated and should be replaced with
`WEB_CONCURRENCY`.

It would also allow us to replace Gunicorn with another web server in
the future without changing the variable name.

[1] https://docs.gunicorn.org/en/stable/settings.html#workers
2025-02-19 00:31:34 -03:00
Georges-Antoine Assi
e5f7a0f335 fix trunk check issue in init script 2025-01-07 10:50:19 -05:00
Mikhail Vazhnov
f5bd75cced fix: Handle terminate signals in init script
`tini` does not wait for child processes to close, so all processes will be killed immediately. This is why the container stops so fast.

This fix makes the `init` script listen and handle terminate signals. It also ensures that child processes are shut down in reverse order with proper waiting for completion.
2024-12-27 01:02:19 +03:00
Michael Manganiello
66e5939b2b misc: Use bundled Valkey instead of Redis server
This change replaces the bundled Redis server with Valkey. No breaking
changes are introduced, as considered environment variables still
maintain the `REDIS_` prefix.

Fixes #925.
2024-09-22 13:27:18 -03:00
Michael Manganiello
27ba5a1159 fix: Set Gunicorn option forwarded-allow-ips
Currently, the `request.url_for` and `URLPath.make_absolute_url` methods
always build URLs with "http" scheme, even when the original requested
URL is using "https".

The reason for this is that Gunicorn does not allow IPs other than
127.0.0.1 to set secure headers by default. As regular RomM
installations don't know which frontend IPs will try to set security
headers in advance, we can disable this validation, and fix URL
building.

A simple way to test this change is to access any of the `feed` endpoints,
which generate URLs using the mentioned methods. Accessing the endpoint
using "https" scheme must generate "https" URLs.

Reference:
* https://github.com/encode/starlette/issues/538#issuecomment-2054013679
* https://docs.gunicorn.org/en/stable/settings.html#forwarded-allow-ips
2024-08-09 01:20:17 -03:00
Michael Manganiello
0daa708a05 misc: Simplify backend environment configuration in Docker image
This change moves the virtualenv creation in the `Dockerfile` to a
separate stage, to simplify isolating the process and reduce the need
for uninstalling build dependencies.

The approach is similar to the one explained in [1]. It relies on
building a virtualenv folder, and copying it in the final stage.
Changing the `PATH` environment variable makes the virtualenv usable by
default, without affecting the default Python installation.

Also, added Dockerfile arguments for Alpine, nginx, and Python versions,
as some of them are reused, and also simplifies testing new versions.

An extra side effect is that the image size for the final stage is
reduced from 315MB to 262MB.

[1] https://scribe.rip/@albertazzir/blazing-fast-python-docker-builds-with-poetry-a78a66f5aed0
2024-06-22 18:19:16 -03:00
Georges-Antoine Assi
c4ef4d92d2 run truck fixes 2024-05-31 19:00:04 -04:00
Georges-Antoine Assi
9b62641d55 Merge branch 'master' into trunk-io 2024-05-31 18:42:43 -04:00
Zurdi
44f10a560c Solve merge into release conflicts 2024-05-31 16:46:35 +02:00
Georges-Antoine Assi
ca1363a93c run chech 2024-05-23 10:14:04 -04:00
Georges-Antoine Assi
10479bdc9f run formatter 2024-05-23 10:06:43 -04:00
Georges-Antoine Assi
fcb34f9088 Merge branch 'master' into trunk-io 2024-05-23 10:06:13 -04:00
Georges-Antoine Assi
b2085f87a8 bunch of fixes for trunk 2024-05-21 17:10:11 -04:00
Georges-Antoine Assi
a7cf0d389a run trunk format on all files 2024-05-21 10:18:13 -04:00
Georges-Antoine Assi
66510c0327 Improve fetch times of platforms endpoint 2024-05-18 17:24:07 -04:00
Georges-Antoine Assi
07dc02aa6a typo 2024-04-28 13:27:00 +00:00
Georges-Antoine Assi
2baa5f2fec Merge branch 'gunicorn-socket-handling' of github.com:zurdi15/romm into gunicorn-socket-handling 2024-04-28 13:10:56 +00:00
Georges-Antoine Assi
f2f2b3b0cd clear leftover pid files 2024-04-28 09:10:10 -04:00
Georges-Antoine Assi
2407e83e1a only wait when creating nginx 2024-04-26 13:09:23 +00:00
Georges-Antoine Assi
f98bbf183e dont create the file manually 2024-04-26 13:05:51 +00:00
Georges-Antoine Assi
138b75c698 handle gunicorn socket creation manually 2024-04-26 08:53:31 -04:00
Georges-Antoine Assi
4863b80eb3 tweak startup text 2024-03-25 22:08:32 +00:00
Psych0D0g
072acb9fec only print patience log one 2024-03-25 23:03:23 +01:00
Psych0D0g
680f2b239d add a log line to ask for patience 2024-03-25 23:02:36 +01:00
Psych0D0g
a06ccb5324 move sleep to the beginning of our while true loop to save innocent CPUs from overheating in case of errornous behaviour 2024-03-25 22:52:10 +01:00
Psych0D0g
de6838df85 make gunicorn log access and error logs to stdout 2024-03-25 22:20:25 +01:00
Psych0D0g
22f8b6115e remove uvicorn function from init 2024-03-25 22:00:49 +01:00
Psych0D0g
dd428e0af9 switch to gunicorn for handling backend app 2024-03-25 21:56:31 +01:00
Psych0D0g
8f5536c69b switch to gunicorn for handling backend app 2024-03-25 21:56:19 +01:00
zurdi
208239b51b fixed REDIS_HOST check 2024-03-25 10:46:28 +01:00
Georges-Antoine Assi
c8dc872a0d remove from init script and use user docker attr 2024-03-24 23:23:10 -04:00
Georges-Antoine Assi
1c7621c4b2 Hotifx PUID/GUID changes in init script 2024-03-24 22:53:54 -04:00
Georges-Antoine Assi
f259e1b1d0 fix scanning after socketio upgrade 2024-03-18 09:47:15 -04:00
Georges-Antoine Assi
be553d5524 add shadow to set ownership 2024-03-18 02:53:27 +00:00
Georges-Antoine Assi
d073657365 Allow setting dynamic PUID/PGID 2024-03-17 19:56:25 -04:00
Georges-Antoine Assi
02f27ace40 disable built in redis if env set 2024-03-17 17:05:26 -04:00
Georges-Antoine Assi
e024fc987f bind redis data volume 2024-03-12 02:07:31 +00:00
Georges-Antoine Assi
a36d49979e [WIP] build redis into container
expose port right
2024-03-01 10:36:02 -05:00
Georges-Antoine Assi
6bcadec702 everything we need for 3.0 2024-02-01 18:13:16 -05:00
Lukas Wingerberg
d4dfda20a3 fix comment 2023-11-02 10:58:05 +01:00
Lukas Wingerberg
51c67a4e5d dont start the watcher.py when we disable rescan on change 2023-11-02 10:53:52 +01:00
Lukas Wingerberg
97f633f608 fix rare case where a socket file could be lingering leading to stsartup errors on uvicorn 2023-11-02 10:18:27 +01:00
Lukas Wingerberg
9204cf3381 Update docker/init_scripts/init
Co-authored-by: Georges-Antoine Assi <GAntoine@users.noreply.github.com>
2023-11-01 09:47:47 +01:00
Lukas Wingerberg
b1ca77e327 Update docker/init_scripts/init
Co-authored-by: Georges-Antoine Assi <GAntoine@users.noreply.github.com>
2023-11-01 09:47:34 +01:00
Lukas Wingerberg
b2ebe36c28 add error_log function that exit 1's implicitely 2023-10-31 23:05:34 +01:00
Lukas Wingerberg
e27a41e9dd simplify the init script a bit to lessen code duplication 2023-10-31 23:02:12 +01:00
Lukas Wingerberg
adf8127295 refactor init script and add error handling via watchdog loop 2023-10-31 22:39:08 +01:00