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

Kill server with client #1184

Merged
merged 2 commits into from
Jul 5, 2015
Merged

Kill server with client #1184

merged 2 commits into from
Jul 5, 2015

Conversation

Malabarba
Copy link
Member

Whenever the nrepl hangs for one reason or another, you have to kill two different buffers each with its own process. This hook makes it easier to kill the server after killing the client.

@@ -724,6 +724,15 @@ If NO-ERROR is non-nil, show messages instead of throwing an error."
;; `nrepl-start-client-process' is called from `nrepl-server-filter'. It
;; starts the client process described by `nrepl-client-filter' and
;; `nrepl-client-sentinel'.
(defun nrepl--maybe-kill-server-buffer ()
"Kill the `nrepl-server-buffer' and its process, subject to use confirmation."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use => user

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also moved the function above that block of comments, since the block is about the following function.

@expez
Copy link
Member

expez commented Jul 3, 2015

This seems like it's duplicating the functionality of cider-quit? Are we doing a too poor job of promoting that function?

@Malabarba
Copy link
Member Author

@expez This is for when the connection hangs. In those cases cider-quit will hang as well trying to close the connection.

@bbatsov
Copy link
Member

bbatsov commented Jul 3, 2015

Btw, reworking cider-quit is high on the todo list. I'm pretty sure most people are surprised that it kills all the connections, instead of only the current one. This makes cider-restart pretty confusing as well.

@bbatsov
Copy link
Member

bbatsov commented Jul 3, 2015

This seems like it's duplicating the functionality of cider-quit? Are we doing a too poor job of promoting that function?

@expez Some people will always try to kill just the current REPL, so this functionality makes sense for me. And as I said cider-quit's current behaviour is definitely not idea. We should definitely be able to kill individual connections and we either need to rename it cider-quit-all and add a different quit command named cider-quit or keep it as is and add a command cider-quit-connection (or something like this).

I still ask myself why this ended up in its current state - most likely because I generally work with only connection and this hasn't been much of an issue for me.

@Malabarba
Copy link
Member Author

Some people will always try to kill just the current REPL, so this functionality makes sense for me.

Not to mention, killing the buffer is a traditionally a viable way of cancelling/stopping things in Emacs, even when a subprocess is involved. So it would be nice for Cider to try to handle that somewhat gracefully too.

We should definitely be able to kill individual connections and we either need to rename it cider-quit-all and add a different quit command named cider-quit or keep it as is and add a command cider-quit-connection (or something like this).

Or change the default behaviour to “quit current” and make the “quit all” behaviour available with a prefix key.

@Malabarba
Copy link
Member Author

But anyway, killing the repl is something I do when it hangs (I suppose it happens more often than it should with me because of all the hacking around the debug middleware :), usually I just cider-quit.

@bbatsov
Copy link
Member

bbatsov commented Jul 3, 2015

Or change the default behaviour to “quit current” and make the “quit all” behaviour available with a prefix key.

Yep, that's a good suggest. Btw, something came to mind - we're killing the connection using a sentinel if the process that created the nrepl server died. Maybe we can use a sentinel for the REPL process as well for consistency. Not sure if we gain anything by this.

@Malabarba
Copy link
Member Author

@bbatsov I had a look the code in nrepl-server-sentinel but I don't quite get something. In the following snippet, why does it close the connection on "hangup" but not on "killed"?

((string-match-p "^killed" event)
  nil)
((string-match-p "^hangup" event)
  (when connection-buffer
    (nrepl-close connection-buffer)))

@bbatsov
Copy link
Member

bbatsov commented Jul 3, 2015

Beats me. I see this was labeled a bug fix in the past https://github.com/clojure-emacs/cider/blob/master/CHANGELOG.md#bugs-fixed-14

Maybe the idea was to be able to kill the server buffer and recycle the REPL buffer or something like this. Guess we can find the PR related to this.

@bbatsov
Copy link
Member

bbatsov commented Jul 3, 2015

Seems to me this was a mistake - #160

@bbatsov
Copy link
Member

bbatsov commented Jul 4, 2015

Btw, in the mean time I've changed the behaviour of cider-quit and cider-restart.

@Malabarba
Copy link
Member Author

I've added something to the client sentinel so that it kills the server process too when the client dies. The server buffer is only offered to be killed if the client buffer is killed. Does it look reasonable?

@bbatsov
Copy link
Member

bbatsov commented Jul 5, 2015

Looks legit. Just add a changelog entry for this.

@Malabarba
Copy link
Member Author

Logged.

bbatsov added a commit that referenced this pull request Jul 5, 2015
@bbatsov bbatsov merged commit ea8f5ed into clojure-emacs:master Jul 5, 2015
@bbatsov
Copy link
Member

bbatsov commented Jul 5, 2015

👍

@Malabarba Malabarba deleted the kill-server-with-client branch July 7, 2015 14:37
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

Successfully merging this pull request may close these issues.

3 participants