Devs ~ tips n tricks n misc - GeoscienceAustralia/egeodesy GitHub Wiki
Stopping npm serve process when doing e2e testing
The problem is that we start the client app with npm run serve.e2e & and of course '&' starts a process. This watches for changes and re-compiles (transpiles etc...), though sometimes you need to restart it. If the existing process still exists then starting a new one will use a different port. So we need to kill it and any others we may have accidentally started.
You could find the processes by running ps aux | grep gulp, however this will show the webdriver process also, which we don't want to kill. Instead do this:
1. Find the pid
$ netstat -vatnp | grep 555 # 5555, 5556, 5557 and any others you may have accidently started
> tcp6 0 0 localhost:5558 localhost:54044 ESTABLISHED 31960/gulp
> tcp6 0 0 localhost:5557 localhost:46290 ESTABLISHED 31789/gulp
We can see that the gulp process running on port 5558 has the pid 31960, and the one running on 5557 has the pid 31789. No process is running on 5555 at the moment.
We can see this by looking at the gulp processes:
brooke 6710 0.2 6.3 1771600 644864 pts/3 Sl Jun23 4:19 gulp
brooke 12015 1.9 5.1 1688024 528688 pts/3 Sl Jun22 59:34 gulp
brooke 31789 13.3 3.9 1554344 400892 pts/3 Sl 13:56 0:35 gulp
brooke 31960 49.2 4.5 1579552 467488 pts/3 Sl 13:59 0:33 gulp
brooke 32082 0.0 0.0 119828 2184 pts/3 S+ 14:01 0:00 grep --color=auto gulp
- Kill the processes
$ kill 31960 31789