Search code examples
unixamazon-web-servicesbackground-processaws-code-deploy

Kill respawing server running on port 3000 created by `node . > /dev/null 2> /dev/null < /dev/null &`


I'm using AWS CodeDeploy in which server running on pm2 dose not work due to explanation given here in troubleShoot documentation.

I followed the documentation and in AfterInstall script used node . > /dev/null 2> /dev/null < /dev/null & to run the node server in the background.

I've tried following ways to kill the server

  • fuser -k 3000/tcp

  • lsof -P | grep ':3000' | awk '{print $2}' | xargs kill -9

  • kill -9 $(lsof -t -i:3000)

but each time a new process respwans with a different PID.

How can I kill this background process and add it to the ApplicationStop script for CodeDeploy?


Solution

  • I was able to kill using pkill node command.