mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Transitions the Docker image to use s6 and s6-overlay for process supervision instead of supervisord (#8886)
This commit is contained in:
28
docker/rootfs/etc/s6-overlay/s6-rc.d/init-search-index/run
Executable file
28
docker/rootfs/etc/s6-overlay/s6-rc.d/init-search-index/run
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/command/with-contenv /usr/bin/bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
declare -r log_prefix="[init-index]"
|
||||
|
||||
declare -r index_version=9
|
||||
declare -r data_dir="${PAPERLESS_DATA_DIR:-/usr/src/paperless/data}"
|
||||
declare -r index_version_file="${data_dir}/.index_version"
|
||||
|
||||
update_index () {
|
||||
echo "${log_prefix} Search index out of date. Updating..."
|
||||
cd "${PAPERLESS_SRC_DIR}"
|
||||
if [[ -n "${USER_IS_NON_ROOT}" ]]; then
|
||||
python3 manage.py document_index reindex --no-progress-bar
|
||||
echo ${index_version} | tee "${index_version_file}" > /dev/null
|
||||
else
|
||||
s6-setuidgid paperless python3 manage.py document_index reindex --no-progress-bar
|
||||
echo ${index_version} | s6-setuidgid paperless tee "${index_version_file}" > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ (! -f "${index_version_file}") ]]; then
|
||||
echo "${log_prefix} No index version file found"
|
||||
update_index
|
||||
elif [[ $(<"${index_version_file}") != "$index_version" ]]; then
|
||||
echo "${log_prefix} index version updated"
|
||||
update_index
|
||||
fi
|
@@ -0,0 +1 @@
|
||||
oneshot
|
@@ -0,0 +1 @@
|
||||
/etc/s6-overlay/s6-rc.d/init-search-index/run
|
Reference in New Issue
Block a user