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

2
env
View File

@@ -18,7 +18,7 @@ UPLOAD_LOCATION=./library
IMMICH_VERSION=release IMMICH_VERSION=release
# Hosts & ports # Hosts & ports
IMMICH_HOST=127.0.0.1
DB_HOSTNAME=127.0.0.1 DB_HOSTNAME=127.0.0.1
MACHINE_LEARNING_HOST=127.0.0.1
IMMICH_MACHINE_LEARNING_URL=http://127.0.0.1:3003 IMMICH_MACHINE_LEARNING_URL=http://127.0.0.1:3003
REDIS_HOSTNAME=127.0.0.1 REDIS_HOSTNAME=127.0.0.1

View File

@@ -112,7 +112,13 @@ python3 -m venv $APP/machine-learning/venv
poetry install --no-root --with dev --with cpu poetry install --no-root --with dev --with cpu
cd .. 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 # Install GeoNames
mkdir -p $APP/geodata mkdir -p $APP/geodata
@@ -157,20 +163,30 @@ set +a
cd $APP/machine-learning cd $APP/machine-learning
. venv/bin/activate . venv/bin/activate
: "\${MACHINE_LEARNING_HOST:=127.0.0.1}" : "\${IMMICH_HOST:=127.0.0.1}"
: "\${MACHINE_LEARNING_PORT:=3003}" : "\${IMMICH_PORT:=3003}"
: "\${MACHINE_LEARNING_WORKERS:=1}" : "\${MACHINE_LEARNING_WORKERS:=1}"
: "\${MACHINE_LEARNING_WORKER_TIMEOUT:=120}" : "\${MACHINE_LEARNING_HTTP_KEEPALIVE_TIMEOUT_S:=2}"
exec gunicorn app.main:app \ exec gunicorn app.main:app \
-k app.config.CustomUvicornWorker \ -k app.config.CustomUvicornWorker \
-c gunicorn_conf.py \
-b "\$IMMICH_HOST":"\$IMMICH_PORT" \
-w "\$MACHINE_LEARNING_WORKERS" \ -w "\$MACHINE_LEARNING_WORKERS" \
-b "\$MACHINE_LEARNING_HOST":"\$MACHINE_LEARNING_PORT" \
-t "\$MACHINE_LEARNING_WORKER_TIMEOUT" \ -t "\$MACHINE_LEARNING_WORKER_TIMEOUT" \
--log-config-json log_conf.json \ --log-config-json log_conf.json \
--keep-alive "\$MACHINE_LEARNING_HTTP_KEEPALIVE_TIMEOUT_S" \
--graceful-timeout 0 --graceful-timeout 0
EOF 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 # Cleanup
rm -rf $TMP rm -rf $TMP