mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-04-27 21:00:40 +00:00
Refactor: centralize systemd service creation (#12025)
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.
This commit is contained in:
committed by
GitHub
parent
0a7bd20b06
commit
32d1937a74
@@ -104,6 +104,10 @@ function update() {
|
|||||||
$STD npm run build
|
$STD npm run build
|
||||||
msg_ok "Built ${APP}"
|
msg_ok "Built ${APP}"
|
||||||
|
|
||||||
|
msg_info "Updating service"
|
||||||
|
create_service
|
||||||
|
msg_ok "Updated service"
|
||||||
|
|
||||||
msg_info "Starting service"
|
msg_info "Starting service"
|
||||||
systemctl start immich-proxy
|
systemctl start immich-proxy
|
||||||
msg_ok "Started service"
|
msg_ok "Started service"
|
||||||
@@ -112,6 +116,27 @@ function update() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_service() {
|
||||||
|
cat <<EOF >"$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
|
# INSTALL
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@@ -173,23 +198,7 @@ EOF
|
|||||||
msg_ok "Created configuration"
|
msg_ok "Created configuration"
|
||||||
|
|
||||||
msg_info "Creating service"
|
msg_info "Creating service"
|
||||||
cat <<EOF >"$SERVICE_PATH"
|
create_service
|
||||||
[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
|
|
||||||
systemctl enable -q --now immich-proxy
|
systemctl enable -q --now immich-proxy
|
||||||
msg_ok "Created and started service"
|
msg_ok "Created and started service"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user