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
Use init:stop to make sure the zotonic node shuts down cleanly #2957
base: master
Are you sure you want to change the base?
Conversation
We added the rather brutal kill as the Maybe we can stop all applications instead? |
Something like?
|
Maybe, I guess we don't have a dependency graph for a clean shutdown? |
Here is the original issue regarding the unloading behaviour. I guess we had this problem even on faster computers because zotonic loads a lot of modules. erlang/otp#5031 |
Yes, I got some complaints from people, especially on non MacBook Pro machines ... |
I don't know if the application module maintains some sort of order. It could be that they just return the applications in reverse order they where started. That would be good I guess. |
Looking at the application list it seems to be that way. |
application:stop(mnesia), | ||
application:stop(epgsql), | ||
|
||
[ application:stop(A) || {A, _, _} <- application:which_applications() ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we first stop the other applications and then the base apps like exometer, jobs and mnesia?
It might be that the other apps want to save something in the databases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes you are right. I noticed the order is important. When it is wrong it can lead to unexpected hangs. Maybe we should just use init:stop/0
. OTP 25 is just around the corner for anybody who complains about slowness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is really slow.
We might also use init:stop/0
if the OTP version is >= 25.
And the other shutdown on older versions.
@mmzeeman can you check my latest change? |
It is reporting a lot of errors.
and stopping again, after it has already stopped.
Will look at it later. The order in which things are taken down is probably wrong. |
Hmm... strange, now it won't stop at all.
|
Maybe we should just do the brute force stop on OTP <= 24, and the nice stop on OTP 25+ |
Make sure started applications are stopped before shutting down the node
Please describe here what the PR does.
erlang:halt(0)
immediately stops the node, without waiting for applications to stopcleanly. Applications which need to do teardown work before stopping will not do this. The
init
application, which coordinates system startup, has a stop function which cleanly handles shutting down the node, and manage heart when needed. See: https://www.erlang.org/doc/man/init.html#stop-1Checklist