From 9910e588b12d3b724e30cbf15cba52167cd71e16 Mon Sep 17 00:00:00 2001 From: Nora Date: Fri, 3 Jul 2026 15:16:01 -0600 Subject: [PATCH] fix(deploy): pm2 restart --update-env so PM2 picks up new env vars on deploy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without --update-env, PM2 caches the original env vars at first start and silently ignores newly added ones — including SMARTSHEET_TOKEN_ENC_KEY and SMARTSHEET_CRON_SECRET, which were getting written to .env but never reaching the running Next.js process. --- .gitea/workflows/deploy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 537b526..382b91a 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -203,6 +203,9 @@ jobs: # Install deps and restart on server echo "Installing deps and restarting PM2..." - ssh -o ConnectTimeout=60 -o StrictHostKeyChecking=no tyler@route.crispygoat.com "cd $APP_DIR && npm install --omit=dev 2>&1 | tail -5 && pm2 restart route-commerce || pm2 start npm --name route-commerce -- start -- -p 3100 && pm2 save && sleep 4 && curl -f -s http://localhost:3100/api/health/db-schema || { echo 'Health check failed after start - schema not applied (see plan)'; exit 1; }" + # IMPORTANT: --update-env so PM2 re-reads .env. Without it PM2 keeps + # the original env vars cached at first start and silently ignores + # newly added ones (like SMARTSHEET_*). + ssh -o ConnectTimeout=60 -o StrictHostKeyChecking=no tyler@route.crispygoat.com "cd $APP_DIR && npm install --omit=dev 2>&1 | tail -5 && pm2 restart route-commerce --update-env || pm2 start npm --name route-commerce -- start -- -p 3100 && pm2 save && sleep 4 && curl -f -s http://localhost:3100/api/health/db-schema || { echo 'Health check failed after start - schema not applied (see plan)'; exit 1; }" echo "Deployed successfully" \ No newline at end of file