Open Artur- opened 5 years ago
The logical way for this would be to provide a npm stop
script, which would stop the server(s).
Some notes for implementers as discussed f2f in the team.
Implementing this requires storing pids of started processes in a file. Usually, the pid files are deleted on during normal shutdown.
Once storing pid files is done, npm start
should check for existing pid files and throw in case if there are any. npm stop
could then also be added to kill any processes in that case.
There are existing solutions for Node for tracking running processes using pid files, like https://github.com/foreverjs/forever-monitor. Let’s consider using them.
Another problem here is that we start the Java backend app indirectly through Maven plugin in the fork mode, and this adds another layer of process runner/monitor into play, so it is not straightforward to get the pid of the backed app. Beware that:
Also, let’s introduce the shared scripts package vaadin/vaadin-connect#324 and tests vaadin/vaadin-connect#325 before this one. Testing is important here, otherwise regressions happen all the time.
AFAIK, npm stop
is uncommon, because npm start
is usually running in the foreground.
We should consider introducing the detached run option for npm start
alongside with npm stop
in order for all to make sense together.
If you run
npm start
and then the terminal window dies for whatever reason, the processes keep running and there is no easy way to stop or restart the server. There should be some way to kill all the related processes of a given project.