Skip to content

Commit

Permalink
Use new shutdown procedure
Browse files Browse the repository at this point in the history
The ycmd server has now a shutdown handler and we need to send a
shutdown request instead of killing the process.

See ycm-core/ycmd#282

Resolves abingham#240
  • Loading branch information
ptrv committed Jan 6, 2016
1 parent e95f605 commit 6c71ef6
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions ycmd.el
Expand Up @@ -610,26 +610,29 @@ control.) The newly started server will have a new HMAC secret."

(ycmd--start-keepalive-timer))

(defun ycmd--shutdown ()
"Send a shutdown request to the server."
(ycmd--request "/shutdown" nil :parser 'json-read))

(defun ycmd-close (&optional time-out-secs)
"Shutdown any running ycmd server.
Wait TIME-OUT-SECS seconds after `interrupt-process' call for the
ycmd server to end before killing the process with
`delete-process'.
Wait TIME-OUT-SECS seconds after a shutdown request for the ycmd
server to end before killing the process with `delete-process'.
This does nothing if no server is running."
(interactive)

(unwind-protect
(when (ycmd-running?)
(condition-case nil
(progn
(interrupt-process ycmd--server-process)
(when time-out-secs
(sit-for time-out-secs)
(delete-process ycmd--server-process)))
(error nil))
(ycmd--global-teardown)))
(when (ycmd-running?)
(unwind-protect
(progn
(ycmd--shutdown)
(when time-out-secs
(sit-for time-out-secs)
(condition-case nil
(delete-process ycmd--server-process)
(error nil))))
(ycmd--global-teardown)))

(ycmd--kill-timer ycmd--keepalive-timer))

Expand Down

0 comments on commit 6c71ef6

Please sign in to comment.