Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 242 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Node JS ctrl + C doesn't stop server (after starting server with "npm start")

#11
I was able to fix this by switching to [nodemon][1] to run the server.

```
npm install --save-dev nodemon
```

**package.json**:

```
"scripts": {
"start": "nodemon app"
},
```

I was trying to get `json-server` to quit a custom server script, but it always left a child process running on Windows. It seems to be a specific problem running `express` via `npm` on Windows. If you run the server directly via the `c:>node server.js` then it seems to quit correctly.


[1]:

[To see links please register here]

Reply

#12
Inside package.json under scripts I had this line `react-scripts start&`. Notice it ends with an `&` which would send the process to the background and `ctrl+c` will not work. Somehow trying to bring this to the foreground with `fg` also did not work. Solved the problem by removing the `&`.
Reply

#13
Ctrl + C does not kill the server. The resolution to the issue was using following code snippet in server.js:

process.on('SIGINT', function() {
console.log( "\nGracefully shutting down from SIGINT (Ctrl-C)" );
// some other closing procedures go here
process.exit(0);
});

This worked for me.

You can also check for other solutions mentioned at [Graceful shutdown in NodeJS][1]



[1]:

[To see links please register here]

Reply

#14
if you use **Node.js Exec** Extention to run your project from **f8**,
you can use also **f9** to cancel running..
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through