Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial server not closed #103

Open
deg opened this issue Dec 20, 2015 · 4 comments
Open

initial server not closed #103

deg opened this issue Dec 20, 2015 · 4 comments

Comments

@deg
Copy link

deg commented Dec 20, 2015

(alert: I'm new to grunt-express-server and many of the surrounding tools, so issue may be little more than my lack of understanding and/or out-of-date docs).

I started using grunt-express-server yesterday, replacing nodemon, because I wanted a toolchain where editing a source file would run my mocha tests and restart my dev server.

I discovered that, even though the tests ran and the server restarted; the server did not seem to be running my latest code. Much head-scratching later, I found that I had been bitten by two issues:

  1. console.log and console.error messages were not appearing on my terminal, making it hard to see that the problem was that the new server instance had failed to fully start. Rather, it was dying because its port was in use. My guess is that this might be an artifact of the process dying without flushing console output. But, dunno. In any event, this is just a side-effect that made it harder to debug problem 2, the real issue.

  2. My gruntfile was started with a task that did ['express:dev', 'watch]. Watch, in turn, listed express:dev as a task.

This did not work -- although I understood it to be what I should do, based on the docs I had read. When the node server was restarted, it did not kill the initial instance, so was not able to grab the port, so died. (and, making matters more confusing, was dying silently).

I fixed the problem by having my initial task just do ['watch'], and giving watch the option atBegin: true.
So, I think I'm ok now. Reporting this issue for the sake of improving docs for the next guy, or in the hope that I've revealed that I've done something stupid that I should fix.

@jlsutherland
Copy link
Collaborator

Hi @deg,

Others have seen a similar issue where the server does not close (#97, #102). It seems like the primary reason people see this issue is because the child process does not respond to the termination command from node (or the command line). The current proposed solution is PR #99.

It is interesting that you were able to solve this issue by replacing your initial task with just ['watch']. If this is the case, it would suggest that the problem has something to do with the grunt file's structure.

Would you mind giving some info on your setup? I'd like to know what version of node you're using, a package.json file, your Gruntfile, and what you replaced nodemon with!

  • Joe

@deg
Copy link
Author

deg commented Dec 20, 2015

I’m happy to help, to the extent I can.

Sadly, I don’t currently have a working case. To debug it, I had added a pile of console.log traces into my code. I pulled them out before I committed. (stupid of me… I’m usually fanatic about checkpointing every micro change, and I should have saved the exact working case). Anyway, it then stopped working in a different way ... the server dies very shortly after starting up. I lacked the tools and time to debug it so, for now, rolled back to my previous configuration … using nodemon on my dev server.

Also, sadly, I can’t share my full project with you. It contains some proprietary code that I’m not allowed to release.

That said, I’ll answer as much as I can, including your questions below.

I’m running node 4.2.3. It’s running in a docker instance, hosted on a Mac running OX X 10.11.2 (El Capitan).

I had been launcher the server with “nodemon -V -L vaServer.js”, and changed that to “grunt dev”

Here’s the package.json (with a few bits elided). Note that some of the dependencies are not currently in use (e.g. the multiple doc packages):

{
"name": "xxx",
"description": "xxx",
"private": true,
"license": "UNLICENSED",
"version": "0.1.0",
"homepage": "xxx",
"repository": {
"type": "git",
"url": "xxx"
},
"devDependencies": {
"chai": "^3.4.1",
"grunt": "^0.4.5",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-jshint": "^0.11.1",
"grunt-contrib-uglify": "^0.8.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-contrib-yuidoc": "^0.7.0",
"grunt-exec": "^0.4.6",
"grunt-express-server": "^0.5.1",
"grunt-git-describe-plus": "^2.3.3-0",
"grunt-jsdoc-ng": "0.0.3",
"grunt-simple-mocha": "^0.4.0",
"qunitjs": "^1.19.0"
},
"dependencies": {
"assert": "^1.3.0",
"async": "^1.5.0",
"body-parser": "^1.14.1",
"express": "^4.13.1",
"jade": "^1.11.0",
"log-timestamp": "^0.1.2",
"marked": "^0.3.4",
"mongodb": "^2.0.49",
"morgan": "^1.6.1",
"nib": "^1.1.0",
"serve-favicon": "^2.3.0",
"stylus": "^0.52.0"
}
}

@jlsutherland
Copy link
Collaborator

Thank you, @deg! Will look further.

@mrfelton
Copy link

This can happen if you are using babel-node to stat your server (via the cmd option).

npm install kexec makes it work.

See foreversd/forever#687 for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants