From 953483ee152516dd60a9e6498664b407c34d40e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Loureiro?= Date: Mon, 9 Jun 2025 16:44:25 -0300 Subject: [PATCH] fix: update deployment scripts to use dynamic DEPLOY_PATH for backend and frontend --- .gitea/workflows/deploy.yml | 4 ++-- backend/ecosystem.config.js | 3 ++- frontend/ecosystem.config.js | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index f28d8d6..a8d5523 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -5,8 +5,6 @@ on: branches: - main - - jobs: deploy: runs-on: website-deploy-runner @@ -66,6 +64,8 @@ jobs: rsync -a --delete --exclude 'frontend/.next/cache/' --exclude '.git/' ./ /var/www/website.joaoloureiro.dev.br/ - name: Restart Applications with PM2 + env: + DEPLOY_PATH: ${{ vars.DEPLOY_PATH }} run: | echo "Restarting applications with PM2..." pm2 startOrRestart backend/ecosystem.config.js --update-env diff --git a/backend/ecosystem.config.js b/backend/ecosystem.config.js index 18d641b..a8f04b2 100644 --- a/backend/ecosystem.config.js +++ b/backend/ecosystem.config.js @@ -1,7 +1,8 @@ module.exports = { apps: [{ name: 'portfolio-backend', // A name for your application in PM2 - script: 'backend/server.js', // The path to the script PM2 will run + script: 'server.js', // The path to the script PM2 will run + cwd: `${process.env.DEPLOY_PATH}/backend`, // Current working directory for the script instances: 1, // Run a single instance of the application autorestart: true, // Automatically restart if the app crashes watch: false, // Do NOT watch for file changes in production diff --git a/frontend/ecosystem.config.js b/frontend/ecosystem.config.js index a71d1dc..1e4dd0a 100644 --- a/frontend/ecosystem.config.js +++ b/frontend/ecosystem.config.js @@ -3,6 +3,7 @@ module.exports = { name: 'portfolio-frontend', // A name for your application in PM2 script: 'npm', // Tell PM2 to run an npm command args: 'start', // The argument to pass to npm, which runs 'next start' + cwd: `${process.env.DEPLOY_PATH}/frontend`, // Current working directory for the script instances: 1, // Run a single instance of the application autorestart: true, // Automatically restart if the app crashes watch: false, // Do NOT watch for file changes in production