-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Newly started spring server gets stopped by SIGHUP at end of run #216
Comments
I'm not sure what would be a good solution. The docs page you linked to suggests using Also note that most recent versions of Rails don't have Spring in the default config anymore: rails/rails#42997 So it might be worth to re-evaluate whether it brings enough benefit for your particular project. |
I've tried but haven't found a way to use
Regarding the usefulness of Spring, you're right, it's something I should probably reconsider. In this particular project, the difference is currently very noticeable: a simple helper spec takes 5s without Spring, 750ms with Spring, but I suppose the startup time could be improved with some effort (e.g. add |
Yeah,
That makes sense. I probably should have tested it first. On the high level, it seems like you'd want to launch In general, I would just recommend launching Spring in a separate terminal with the same env, so that it picks up the rspec launches as well. And here's a corresponding recommendation for when it's difficult to keep the terminal running: rails/spring#343 |
I haven't found one either. Adding
Exactly. I should have mentioned, this has been my workflow for many years now: run specs in Emacs, notice slow startup, switch to terminal, run any spec there to start spring, switch back to Emacs. It's only a minor annoyance, which I was hoping to be easy to fix once and for all , but apparently it isn't 😄. I've tried to find out from where exactly |
Pretty good, indeed.
I don't know for sure. But the intent might be that, when you close all the open terminals with
It seems that's just how processes work: the compilation runs spring and rspec as a shell command, meaning a shell process is launched to handle it. But then it finishes and the parent process is terminated, and the OS sends SIGHUP to all its children that are still around. See also the explanation here: https://serverfault.com/a/117153, quoting "Advanced Programing in the Unix Environment". |
That makes sense. Therefore, trying to suppress the signal being sent from Emacs is not the right approach. After another look at spring I found an irresistibly simple way to fix it (for me) by monkey patching spring from its user config file: # ~/.spring.rb:
Spring::IGNORE_SIGNALS << "HUP" I'll use this approach now, so far it works exactly as needed. Thanks a lot for the guidance! |
For the record, this comment clarifies the intention of spring on this matter: rails/spring#575 (comment), which I think is a good reason to keep it a local config hack instead of trying to make it configurable within spring itself. |
Assuming a rails project and rspec-mode are configured to use spring, e.g. with
bin/spring
: when no spring server was running yet, starting an rspec-mode compilation starts the spring server process as expected, but stops it immediately after the compilation run finishes instead of keeping it running.When the spring server was started outside of Emacs before, e.g. from a terminal, this is not an issue – the running server is used by the compilation and keeps running after the compilation is finished.
The problem is that Emacs' compilation sends a SIGHUP on completion, but spring traps only SIGINT and SIGQUIT, not SIGHUP – stopping the server when the user closes the terminal is the desired behavior (I read somewhere on spring's GitHub issues).
What would be a good way to prevent the server getting stopped? Is there a way to configure rspec-mode / compilation-mode to not send that signal? Or is there something on spring that can be done about it?
The text was updated successfully, but these errors were encountered: