Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

gocode-gomod daemon stays running after closing VSCode #2132

Closed
ssergiienko opened this issue Nov 19, 2018 · 5 comments · Fixed by #2137
Closed

gocode-gomod daemon stays running after closing VSCode #2132

ssergiienko opened this issue Nov 19, 2018 · 5 comments · Fixed by #2137

Comments

@ssergiienko
Copy link

ssergiienko commented Nov 19, 2018

Steps to Reproduce:

  1. Open any Go project with Go modules and use auto-completion feature
  2. Close VSCode

Actual result: daemon stays running in your system
Expected: It should be stopped with VSCode like original "gocode" daemon

Go extension v0.7.0

@oneslash
Copy link
Contributor

oneslash commented Nov 20, 2018

I was trying to debug it and found this, #2134 it might be related.
What do you think @ramya-rao-a

EDIT: It is not related

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Nov 20, 2018

It should be stopped with VSCode like original "gocode" daemon

The original "gocode" daemon was never stopped either

See #26 (comment)

@ssergiienko
Copy link
Author

ssergiienko commented Nov 20, 2018

@ramya-rao-a Don't you think that it's slightly strange to ask users to do manual pkill gocode/gocode-gomod each time after closing IDE? 😕

As a proposed solution for this ticket and for #26 why not just save PID and internal flag "started_by_vscode" and stop daemon on this condition:
if started_by_vscode == True AND pid == saved_pid then stop_daemon().

It's easy to implement and it will work for all cases except for super corner case when User stared VSCode then start another editor which is also use gocode but unable to restart it itself, and then close VSCode.

@ramya-rao-a
Copy link
Contributor

Yes, that can be done.

The trick is to determine if gocode was started by VS Code or not.

When the Go extension deactivates which is when the VS Code window is closed/reloaded, we can add a step that cleans up the running gocode process if it was started by VS Code.

PRs are most welcome if you want to give this a try.

Code Pointers:

@ramya-rao-a ramya-rao-a reopened this Nov 21, 2018
ramya-rao-a pushed a commit that referenced this issue Nov 29, 2018
* Close gocode daemon on deactivation

Note that the extension doesn't actually start the gocode daemon,
the gocode client itself does that as necessary.

It is safe to close the daemon for the same reason however.
If other clients were using the daemon, it will be restarted
on their next request.

Fixes #2132

* Fix linting error

* Close gocode only if its found
@ramya-rao-a
Copy link
Contributor

The fix for this is now out in the latest update to the Go extension (0.8.0)
Thanks @zmb3!

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants