I’m using aaPanel to manage a Node.js project running on port 40636. I’ve noticed something strange and would like help understanding it.
Here’s what happens:
• When I restart the project using the aaPanel “Restart” button, the .pid file located at:
/www/server/nodejs/vhost/pids/40636_app_web_menu.pid
gets updated with a new PID.
• But when I run:
sudo lsof -i :40636
it shows a different PID (usually the old one), indicating the process on the port hasn’t actually changed.
So even though the PID file says a new process has started, the port is still bound to the old one. I suspect the restart script in aaPanel might not be killing the old process properly before starting the new one.
Here’s the script I use (default aaPanel setup):
PATH=/www/wwwroot/app_web_menu//node_modules/.bin:/www/server/nodejs/v22.17.0/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
export NODE_PROJECT_NAME="40636_app_web_menu"
cd /www/wwwroot/app_web_menu/
nohup /www/server/nodejs/v22.17.0/bin/npm run start >> /www/server/nodejs/vhost/logs/40636_app_web_menu.log 2>&1 &
echo $! > /www/server/nodejs/vhost/pids/40636_app_web_menu.pid
Has anyone else faced this issue?
• Is the aaPanel restart process not stopping the old Node process correctly?
• Should I manually kill the old process using lsof before starting a new one?
• Any suggestions to fix this so the PID file and port match correctly?