From fcd0a6faaa108320af8e3a03b1f4623c03e4a287 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Tue, 17 Feb 2026 10:59:58 +0100 Subject: [PATCH] Refactor: centralize systemd service creation Introduce create_service() to generate the immich-proxy systemd unit and run systemctl daemon-reload. Replace duplicated heredoc service blocks in install with a call to create_service, and invoke create_service during update before starting the service. Adjust unit WorkingDirectory to ${INSTALL_PATH}/app and ExecStart to run dist/index.js. --- tools/addon/immich-public-proxy.sh | 43 ++++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/tools/addon/immich-public-proxy.sh b/tools/addon/immich-public-proxy.sh index c98a92708..a147f80d1 100644 --- a/tools/addon/immich-public-proxy.sh +++ b/tools/addon/immich-public-proxy.sh @@ -104,6 +104,10 @@ function update() { $STD npm run build msg_ok "Built ${APP}" + msg_info "Updating service" + create_service + msg_ok "Updated service" + msg_info "Starting service" systemctl start immich-proxy msg_ok "Started service" @@ -112,6 +116,27 @@ function update() { fi } +function create_service() { + cat <"$SERVICE_PATH" +[Unit] +Description=Immich Public Proxy +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=${INSTALL_PATH}/app +EnvironmentFile=${CONFIG_PATH}/.env +ExecStart=/usr/bin/node ${INSTALL_PATH}/app/dist/index.js +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target +EOF + systemctl daemon-reload +} + # ============================================================================== # INSTALL # ============================================================================== @@ -173,23 +198,7 @@ EOF msg_ok "Created configuration" msg_info "Creating service" - cat <"$SERVICE_PATH" -[Unit] -Description=Immich Public Proxy -After=network.target - -[Service] -Type=simple -User=root -WorkingDirectory=${INSTALL_PATH} -EnvironmentFile=${CONFIG_PATH}/.env -ExecStart=/usr/bin/node ${INSTALL_PATH}/app/server.js -Restart=always -RestartSec=10 - -[Install] -WantedBy=multi-user.target -EOF + create_service systemctl enable -q --now immich-proxy msg_ok "Created and started service"