I've been on this post for the answer: Node / Express: EADDRINUSE, Address already in use - Kill server
Although I don't think that it answers my question, as I wouldn't like to kill the running process but to restart the service.
$ npm run start
> graphql-basics@1.0.0 start /home/phill/Documents/graphql-course/graphql-basics
> nodemon src/index.js --exec babel-node
[nodemon] 1.17.5
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `babel-node src/index.js`
The server is up!
[nodemon] restarting due to changes...
[nodemon] starting `babel-node src/index.js`
events.js:174
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::4000
Basically it restarts the server without killing the previous process?
Manually killing the process won't fix this issue
this is my package.json
{
"name": "graphql-basics",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon src/index.js --exec babel-node",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"graphql-yoga": "^1.14.10"
},
"devDependencies": {
"nodemon": "^1.17.5"
}
}
const server = new GraphQLServer({
typeDefs,
resolvers
})
server.start(() => {
console.log('The server is up!')
})
//should i use process.on('SIGTERM',...) and kill it somehow?