Git Product home page Git Product logo

Comments (9)

fsouza avatar fsouza commented on June 12, 2024 4

Yeah, right now we don't terminate idle daemons, but it's a good idea. Perhaps we can coordinate with @mantoni to see if they'd be interested in having that feature as part of core_d (something like CORE_D_MAX_IDLE_TIME). To be 100% precise we may need to make some changes in the client too to ensure that it retries/reconnects if the server shuts down right before it can send a request.

If this doesn't make sense within core_d, we can implement it just for prettierd.

from prettierd.

mantoni avatar mantoni commented on June 12, 2024 3

That is something being requested for eslint_d as well here: mantoni/eslint_d.js#236

It makes sense to put the core functionality into core_d so that it can be shared with this project too.

I don't have the time right now to do the leg work, but I'd happily assist, review and integrate.

from prettierd.

sQVe avatar sQVe commented on June 12, 2024 2

I have this workaround, that I've been using for a long while, that you can use until this feature is provided in core_d.

Start by registering an autocmd for a ExitPre event. The callback of the autocmd executes a detached script.

This is how I've set it up:

-- Stop Neovim Daemons.
autocmd('ExitPre', {
  group = augroups.StopNeovimDaemons,
  callback = function()
    vim.fn.jobstart(
      vim.fn.expand('$SCRIPTS') .. '/nvim/stop-nvim-daemons.sh',
      { detach = true }
    )
  end,
})

Next you need to create the stop-nvim-daemons script. This script stops all listed daemons after a set amount of time (in our case 5 minutes).

This is my script that kill both eslint_d and prettierd:
https://github.com/sQVe/scripts/blob/14c628dcdfaca4c1e11208c78e124dbcf52c956e/nvim/stop-nvim-daemons.sh#L1-L33

from prettierd.

fsouza avatar fsouza commented on June 12, 2024 1

Or you can have a 5 line simple autocmd with a killall job

vim.api.nvim_create_autocmd("VimLeavePre", {
	callback = function()
		vim.fn.jobstart("killall prettierd eslint_d", { detach = true })
	end,
})

That is not a good idea as it'll kill all instances of prettierd regardless of whether or not it was created by the current instance of the editor.

If it works for you, great :D but we can't add it to the readme.

from prettierd.

sQVe avatar sQVe commented on June 12, 2024

This is the whole point behind prettierd and other similar CLIs. It's a daemonized prettier version, which improves performance substantially since it removes the node startup time.

from prettierd.

wr9dg17 avatar wr9dg17 commented on June 12, 2024

@sQVe thank you for reply!

I can understand that, it can improve startup/initialization time and as far as I understood this is some kind of caching mechanism. But in other hand I'm not sure if it is normal to have multiple prettierd processes in memory created couple of days ago. Is there a way to add some job to check how much time passed and kill "stale" processes?

from prettierd.

towry avatar towry commented on June 12, 2024
企业微信截图_6cd84fb0-3518-4de1-8fbf-176dd61a4ea2

totally forgotten.

from prettierd.

Tronikelis avatar Tronikelis commented on June 12, 2024

Or you can have a 5 line simple autocmd with a killall job

vim.api.nvim_create_autocmd("VimLeavePre", {
	callback = function()
		vim.fn.jobstart("killall prettierd eslint_d", { detach = true })
	end,
})

from prettierd.

Tronikelis avatar Tronikelis commented on June 12, 2024

That is not a good idea as it'll kill all instances of prettierd regardless of whether or not it was created by the current instance of the editor.

Yeah I understand, when I need to work on multiple projects at once I don't close separate nvim instances, so it works for me. This is just how I workaround this, maybe it will be useful to someone else :)

from prettierd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.