Match upstream's machine learning host

Also, implement a migration process.

Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
This commit is contained in:
Juhyung Park
2024-10-17 13:24:56 +09:00
parent c05ba182e9
commit d0eba74b07
2 changed files with 27 additions and 11 deletions

View File

@@ -112,7 +112,13 @@ python3 -m venv $APP/machine-learning/venv
poetry install --no-root --with dev --with cpu
cd ..
)
cp -a machine-learning/ann machine-learning/start.sh machine-learning/app $APP/machine-learning/
cp -a \
machine-learning/ann \
machine-learning/start.sh \
machine-learning/log_conf.json \
machine-learning/gunicorn_conf.py \
machine-learning/app \
$APP/machine-learning/
# Install GeoNames
mkdir -p $APP/geodata
@@ -157,20 +163,30 @@ set +a
cd $APP/machine-learning
. venv/bin/activate
: "\${MACHINE_LEARNING_HOST:=127.0.0.1}"
: "\${MACHINE_LEARNING_PORT:=3003}"
: "\${IMMICH_HOST:=127.0.0.1}"
: "\${IMMICH_PORT:=3003}"
: "\${MACHINE_LEARNING_WORKERS:=1}"
: "\${MACHINE_LEARNING_WORKER_TIMEOUT:=120}"
: "\${MACHINE_LEARNING_HTTP_KEEPALIVE_TIMEOUT_S:=2}"
exec gunicorn app.main:app \
-k app.config.CustomUvicornWorker \
-w "\$MACHINE_LEARNING_WORKERS" \
-b "\$MACHINE_LEARNING_HOST":"\$MACHINE_LEARNING_PORT" \
-t "\$MACHINE_LEARNING_WORKER_TIMEOUT" \
--log-config-json log_conf.json \
--graceful-timeout 0
-k app.config.CustomUvicornWorker \
-c gunicorn_conf.py \
-b "\$IMMICH_HOST":"\$IMMICH_PORT" \
-w "\$MACHINE_LEARNING_WORKERS" \
-t "\$MACHINE_LEARNING_WORKER_TIMEOUT" \
--log-config-json log_conf.json \
--keep-alive "\$MACHINE_LEARNING_HTTP_KEEPALIVE_TIMEOUT_S" \
--graceful-timeout 0
EOF
# Migrate env file
if [ -e "$IMMICH_PATH/env" ]; then
if grep -q "^MACHINE_LEARNING_HOST=" "$IMMICH_PATH/env"; then
# Simply change MACHINE_LEARNING_HOST to IMMICH_HOST
sed -i -e 's/MACHINE_LEARNING_HOST/IMMICH_HOST/g' "$IMMICH_PATH/env"
fi
fi
# Cleanup
rm -rf $TMP