Fix PM2 UID type error by using login shell and explicit undefined
All checks were successful
Cloud Node Container / Build-and-Push (18) (push) Successful in 1m47s
Cloud Node Container / Build-and-Push (20) (push) Successful in 1m52s
Cloud Node Container / Build-and-Push (22) (push) Successful in 2m0s

- Use su with login shell (-) to ensure clean environment
- Explicitly set uid/gid to undefined in ecosystem config
- This prevents PM2 from trying to parse string UID as integer

The error occurred because PM2 was receiving '1002' as a string
instead of an integer. By using a login shell and explicitly
setting uid/gid to undefined, PM2 won't try to switch users.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-07-24 10:02:17 -07:00
parent aeb934d93e
commit a9dd0573ca
2 changed files with 4 additions and 1 deletions

View File

@@ -92,7 +92,8 @@ fi
# Start PM2 as the user with HOME environment set # Start PM2 as the user with HOME environment set
echo "Starting PM2 as user $user..." echo "Starting PM2 as user $user..."
cd /home/$user/app 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 # Give PM2 time to start
sleep 5 sleep 5

View File

@@ -49,6 +49,8 @@ module.exports = {
kill_timeout: 3000, kill_timeout: 3000,
wait_ready: false, wait_ready: false,
listen_timeout: 3000, listen_timeout: 3000,
uid: undefined,
gid: undefined,
env: { env: {
NODE_ENV: 'development', NODE_ENV: 'development',
PORT: 3000, PORT: 3000,