mirror of
https://github.com/sissbruecker/linkding.git
synced 2026-02-28 06:53:12 +08:00
Add option to run supervisor as main process (#1270)
* Add option to run supervisor as main process * use new option in test script
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
!/postcss.config.js
|
||||
!/pyproject.toml
|
||||
!/rollup.config.mjs
|
||||
!/supervisord.conf
|
||||
!/supervisord-tasks.conf
|
||||
!/supervisord-all.conf
|
||||
!/uv.lock
|
||||
!/uwsgi.ini
|
||||
!/version.txt
|
||||
|
||||
12
bootstrap.sh
12
bootstrap.sh
@@ -27,10 +27,14 @@ python manage.py migrate_tasks
|
||||
# Ensure folders are owned by the right user
|
||||
chown -R www-data: /etc/linkding/data
|
||||
|
||||
# Start background task processor using supervisord, unless explicitly disabled
|
||||
# Start processes
|
||||
# Experimental: use supervisor to manage all processes, enables logging background tasks to stdout/stderr
|
||||
if [ "$LD_SUPERVISOR_MANAGED" = "True" ]; then
|
||||
exec supervisord -c supervisord-all.conf
|
||||
# Default: start background task processor as daemon, then uwsgi as main process
|
||||
else
|
||||
if [ "$LD_DISABLE_BACKGROUND_TASKS" != "True" ]; then
|
||||
supervisord -c supervisord.conf
|
||||
supervisord -c supervisord-tasks.conf
|
||||
fi
|
||||
|
||||
# Start uwsgi server
|
||||
exec uwsgi --http $LD_SERVER_HOST:$LD_SERVER_PORT uwsgi.ini
|
||||
fi
|
||||
|
||||
@@ -48,6 +48,18 @@ Disables background tasks, such as creating snapshots for bookmarks on the [the
|
||||
Enabling this flag will prevent the background task processor from starting up, and prevents scheduling tasks.
|
||||
This might be useful if you are experiencing performance issues or other problematic behaviour due to background task processing.
|
||||
|
||||
### `LD_SUPERVISOR_MANAGED` (Experimental)
|
||||
|
||||
Values: `True`, `False` | Default = `False`
|
||||
|
||||
Changes how processes are managed within the container.
|
||||
When enabled, supervisor manages both the background task processor and the web server (uwsgi).
|
||||
This enables background task logs to appear in the container output (visible via `docker logs`).
|
||||
At the moment, supervisor will automatically restart crashed processes and the `LD_DISABLE_BACKGROUND_TASKS` setting is ignored.
|
||||
|
||||
When disabled (default), the background task processor runs as a daemon and uwsgi runs as the main process.
|
||||
Background task logs are written to a file (`background_tasks.log`) instead of the container output.
|
||||
|
||||
### `LD_DISABLE_URL_VALIDATION`
|
||||
|
||||
Values: `True`, `False` | Default = `False`
|
||||
|
||||
@@ -9,4 +9,5 @@ docker rm -f linkding-local || true
|
||||
docker run --name linkding-local --rm -p 9090:9090 \
|
||||
-e LD_SUPERUSER_NAME=admin \
|
||||
-e LD_SUPERUSER_PASSWORD=admin \
|
||||
-e LD_SUPERVISOR_MANAGED=True \
|
||||
sissbruecker/linkding:local
|
||||
|
||||
37
supervisord-all.conf
Normal file
37
supervisord-all.conf
Normal file
@@ -0,0 +1,37 @@
|
||||
# Supervisor config that manages both uwsgi and background jobs
|
||||
# Used when LD_SUPERVISOR_MANAGED is enabled, which also enables logging background tasks output to container logs
|
||||
[supervisord]
|
||||
user=root
|
||||
nodaemon=true
|
||||
loglevel=info
|
||||
|
||||
[program:uwsgi]
|
||||
command=/bin/bash -c 'uwsgi --http ${LD_SERVER_HOST:-[::]}:${LD_SERVER_PORT:-9090} uwsgi.ini'
|
||||
stdout_logfile=/dev/fd/1
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/fd/2
|
||||
stderr_logfile_maxbytes=0
|
||||
stopasgroup=true
|
||||
autorestart=true
|
||||
|
||||
[program:jobs]
|
||||
user=www-data
|
||||
# setup a temp home folder for the job, required by chromium
|
||||
environment=HOME=/tmp/home
|
||||
command=python manage.py run_huey -f
|
||||
stdout_logfile=/dev/fd/1
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/fd/2
|
||||
stderr_logfile_maxbytes=0
|
||||
stopasgroup=true
|
||||
autorestart=true
|
||||
|
||||
[unix_http_server]
|
||||
file=/var/run/supervisor.sock
|
||||
chmod=0700
|
||||
|
||||
[rpcinterface:supervisor]
|
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||
|
||||
[supervisorctl]
|
||||
serverurl=unix:///var/run/supervisor.sock
|
||||
Reference in New Issue
Block a user