wysiib / linter-languagetool

Integration of Languagetool into the Atom text editor.
MIT License
17 stars 5 forks source link

Multiple Windows - Closing Initial Window Shuts Down Server #25

Open davidlday opened 6 years ago

davidlday commented 6 years ago

This is probably a pretty rare situation. I happened to have multiple windows open, and when I closed the original window, the LanguageTool service was shut down, causing errors on lint in the remaining opened windows.

I have some thoughts on how to address this, but my coffeescript / javascript / node skills are weak so not sure I could implement either of these.

  1. Create one instance of the LanguageTool service using a random available port for each window (i.e. each time the plugin is activated). Each window would have it's own service to use and shutdown on deactivate. The LanguageTool for Visual Studio Code plugin takes this approach. This would also eliminate the need for assigning a port value in the configuration.
  2. In the deactivate function, check to see if any other instances of linter-languagetool are running. If they are, leave the service running. Last one out turns off the lights, so to speak. I like this approach as it limits the amount of resources needed for LanguageTool.
wysiib commented 6 years ago

I don't think the second version is the way to go - for me, ideally, different processes and windows should stay as separated as possible. No need to interfere with each other. The LanguageTools server consumes close to nothing if no checks are running, so keeping around another instance should not be critical. @hesstobi: I guess that issue is related to the startup / shutdown code in your latest pull request?

hesstobi commented 6 years ago

Yes I didn't properly test the situation with multiple windows. Another possibility to solve the problem is to restart the server in the remaining window if the check fails with a connection error. As far as I can tell, LanguageTool uses a lot of memory.

wysiib commented 6 years ago

In that case, detecting a missing / not running / crashed LanguageTool server is probably the way to go.