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

Periodically auto restart #670

Open
mollerhoj opened this issue Jan 10, 2022 · 5 comments
Open

Periodically auto restart #670

mollerhoj opened this issue Jan 10, 2022 · 5 comments

Comments

@mollerhoj
Copy link

mollerhoj commented Jan 10, 2022

Call me crazy, but once in a while I need to restart spring to fix some issue. Usually, I have to go through a painful debugging phase before realizing that I need to restart the spring server.

I noticed that other people feel the same way:

I was thinking: How about an option to auto restart spring at some interval, say, every 10 seconds? I havn't really looked into the internals of spring, but since it's already quite fast for me to just manually restart it every few seconds in the terminal I imagine that internal functionality could make the process even smoother.

It seems to me that this allows me to get all the advantages of spring without having to deal with the disadvantages.

Looking forward to hearing from folks that know more about this gem.

@rafaelfranca
Copy link
Member

This would be mostly a workaround and I prefer to fix the cause instead of resting the server every X minutes. If you have a way to reproduce this problem let us know so we can focus in fixing the problems.

@mollerhoj
Copy link
Author

mollerhoj commented Jan 10, 2022

@rafaelfranca I appreciate the philosophy that we wish to actually fix the issues instead applying ducktape solutions. That's just the right engineering mindset.

However, in this particular case, I don't think that's what's happening. In the first article I linked, an example is given about a case where spring depends on something unwatchable.

In real-world scenarios, I think it might be simply impossible to detect and react to anything that could change the state of the application.

I believe rails removed spring as default because in the few cases where this happens, it can be very time-consuming. That's actually a testiment to how well spring works most of the time, because you don't expect it to be the culprit.

I would suggest it's not a black and white case of either the changes were detected, or spring has problems. I believe we might be able to find some pragmatic middleground?

@matthewd
Copy link
Member

It seems to me that this allows me to get all the advantages of spring without having to deal with the disadvantages.

I'm a bit confused... if you restart spring every few seconds, what benefit does it give you?

@mollerhoj
Copy link
Author

mollerhoj commented Jan 12, 2022

It seems to me that this allows me to get all the advantages of spring without having to deal with the disadvantages.

I'm a bit confused... if you restart spring every few seconds, what benefit does it give you?

When I want to run a spec, it's fast because spring has preloaded the application. Thats the advantage. The disadvantage is that a few times a week, spring will fail to detect some change and needs to be restarted - I do that periodically so I don't have to think about it.

Edit: Sorry, I just looked in the script I made that does this: I also run a dummy spec, just to trigger reloading the application. This could be avoided by just triggering an application reload periodically instead, which is what I'm proposing. I hope that clears up the confusion @matthewd

Come to think of it, I could probably just touch one of the files (like the application config) that causes a full restart periodically. I still think its worth considering making this a built in option.

@mollerhoj mollerhoj changed the title Periodically auto restart server Periodically auto restart Jan 12, 2022
@technicalpickles
Copy link
Contributor

We've run into this as well in our monolith. I haven't been able to consistently reproduce it though, but my hunch is that it can happen when lots of files change at the same time.

One way I've worked around this is to have a post-checkout git hook which stops spring. My thinking is that is the time that the most files are likely to change. In practice, I do end up on a branch for a bit of time to get the benefits of spring, while removing the headache of realizing spring needed to be restarted.

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

4 participants