diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index d2baea9..9e3749a 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -92,7 +92,8 @@ fi # Start PM2 as the user with HOME environment set echo "Starting PM2 as user $user..." cd /home/$user/app -su -c "HOME=/home/$user NODE_ENV=production pm2 start ecosystem.config.js --no-daemon" $user & +# Use su with login shell to ensure clean environment +su - $user -c "cd /home/$user/app && NODE_ENV=production pm2 start ecosystem.config.js --no-daemon" & # Give PM2 time to start sleep 5 diff --git a/scripts/generate-ecosystem-config.sh b/scripts/generate-ecosystem-config.sh index cce069b..0e2b4c7 100755 --- a/scripts/generate-ecosystem-config.sh +++ b/scripts/generate-ecosystem-config.sh @@ -49,6 +49,8 @@ module.exports = { kill_timeout: 3000, wait_ready: false, listen_timeout: 3000, + uid: undefined, + gid: undefined, env: { NODE_ENV: 'development', PORT: 3000,