diff --git a/install.sh b/install.sh index bb3b4c0..abd924f 100755 --- a/install.sh +++ b/install.sh @@ -90,6 +90,10 @@ if [ "${1:-}" = "-update" ]; then sudo_if rsync -a --delete static/ "$INSTALL_DIR/static/" 2>/dev/null || true sudo_if cp install.sh "$INSTALL_DIR/" 2>/dev/null || true + # Stop service before rebuilding so the old binary can be removed. + info "Stopping service..." + sudo_if systemctl stop "$SERVICE_NAME" 2>/dev/null || true + info "Rebuilding binary..." if command -v go &>/dev/null; then export GOMODCACHE="${INSTALL_DIR}/.go/mod" @@ -112,8 +116,8 @@ if [ "${1:-}" = "-update" ]; then # Fix ownership of all files (build cache may be root-owned from earlier builds). sudo_if chown -R "${APP_USER:-${SUDO_USER:-$(whoami)}}:${APP_USER:-${SUDO_USER:-$(whoami)}}" "$INSTALL_DIR" 2>/dev/null || true - info "Restarting service..." - sudo_if systemctl restart "$SERVICE_NAME" + info "Starting service..." + sudo_if systemctl start "$SERVICE_NAME" sleep 2 if systemctl is-active --quiet "$SERVICE_NAME"; then