-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Server doesn't shut down with Ctrl+C #2875
Comments
The cause of this issue is probably causing the current tests with postgres to fail. https://travis-ci.org/ParsePlatform/parse-server/jobs/171414959 In spec/helper.js
is throwing an exception most likely because the preceding
couldn't close the server. |
My observation in the previous comment was incorrect (the recent PRs are passing all tests) It was actually the express server which was keeping connections on for the default timeout period. Once those sockets are closed (as done in #2959) this problem goes away |
This is not the express server getting keeping the connections, and if it ever was we'd see that behaviour with mongodb too. Given the documentation of pg-promise, and that we don't call pgp.end() nor client.release() I would expect that to cause this issue. I believe your PR works because you're also closing the pg connections but that's really not clean. |
I'll take a closer look at this. I haven't yet tested this with mongodb but will try to do so. I'll also see if I can add some tests to check against this behaviour. I've added a note on #2959 to not merge it yet. |
That doesn't make sense that express would retain those connections, that would mean that everyone using express would have that behaviour... I would look into postgres as I mentioned, the pg-promise library explicitly ask to call pgp.end. |
Yes. I'll begin with looking at pgp |
Also, if the issue is really on our express app side, this should not be handled into the CLI, but into the parse-server module itself. |
I've just tested this with mongodb (fresh install on a fresh VM) and the same issue exists. It doesn't seem to be Postgres specific |
The In a way, parse server is actually behaving as it should. The question is should it close all open connections immediately when it receives SIGTERM/SIGINT? |
I believe the HTTP server should close those connections. But that's odd that we have to manually manage it. |
I had submitted a PR for this but I've closed that. I'd actually prefer to write tests to test this behavior first. However, I'm not sure of what the best approach would be. Should the tests spawn parse-server as a child process and test this behavior against that. Or should the code in |
In the unit tests, we ensure no connection is left open after each test, which is odd... I believe your were on the right track can we try something in those likes: https://github.com/isaacs/server-destroy/blob/master/index.js |
That's because the requests made in the tests don't use request.get({
.
.
agent: new require('http').Agent({keepAlive: true})
}, (error, response, body) => {
.
.
.
}); the test would fail with the message that there were open connections. (This is the default behavior for browsers so maybe the tests should be modified like this?) This is apparently a known issue with nodejs nodejs/node#2642 There's also a PR open that attempts to partially fix this nodejs/node#2534. It seems to have been open for a long time, though. Based on the discussion around this issue in the node repo, it isn't certain if we'll be seeing a fix for this anytime soon. It does seem to be a bug in node because none of the other servers (nginx, apache, etc) exhibit this behavior. They close all connections when they receive a signal to close. |
I'm still having this issue when using parse server as express middleware. What i'm doing wrong? (MacOS 10.12.4, node v7.9.0) |
See: #3718 |
@flovilmart missed that issue. Thanks! |
When using parse server with the Postgres database adapter,the server doesn't shut down whenCTRL+C
is pressed.Steps to reproduce
Start parse server:
Start parse dashboard and point it to this
Open the parse dashboard in a browser (
http://localhost:4040/apps
)Stop parse dashboard (this step isn't necessary)
Try to stop parse server by pressing
CTRL+C
in the terminal where it was started.Expected Results
Parse server stops
Actual Outcome
The following message is displayed and the server hangs:
If
CTRL+C
is pressed repeatedly (about 10-12 times), the following message is displayed:Note that if parse dashboard isn't used,
CTRL+C
works as expected and parse server shuts down.Environment Setup
Note: this issue is also present when using the release 2.2.22. However, with this release, some code has to be modified to use the Postgres adapter.
Logs/Trace
The text was updated successfully, but these errors were encountered: