fix: stop service before build so old binary can be removed
- Prevents 'text file busy' error when rebuilding running binary - Service is started again after the build completes
This commit is contained in:
parent
f8d3cb6b33
commit
5abe8c49d9
1 changed files with 6 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue