ra-multiplex icon indicating copy to clipboard operation
ra-multiplex copied to clipboard

built-in process management

Open untitaker opened this issue 3 years ago • 2 comments

in order for this to be a full drop-in replacement it could be cool to:

  1. start ra-multiplex-server if it's not already running from within ra-multiplex
  2. have ra-multiplex-server shut down if it no longer holds any rust-analyzer instances

untitaker avatar Feb 04 '22 17:02 untitaker

This functionality can be emulated by starting the server automatically every time you open your editor. Since it is trying to bind to the same port, it will just silently fail if there is already a server running.

Using Vim:

if executable('ra-multiplex-server')
    autocmd FileType rust silent !(&>/dev/null ra-multiplex-server &)
endif

oysols avatar Oct 23 '22 12:10 oysols

Just wanted to note that I tried to implement the original proposal but haven't finished anything yet because there isn't any cross-platform solution for daemonizing processes.

The crate daemonize seems to be the most portable way of implementing this at least on unix-like OSs, but it requires me to split the implementation from other platforms and forces me to tackle and decide on things that should be left for other process management tools, like where to log.

While I understand the appeal of the convenience this feels very out-of-scope for ra-mux-server, I'd consider a systemd user unit as a betterreplacement for most unix systems. Adding an example how to configure that in the documentation would be my prefered solution.

pr2502 avatar Oct 23 '22 16:10 pr2502

Here's what I'm using:

[Unit]
Description=Rust analyzer multiplexer server

[Service]
Type=simple
ExecStart=/usr/bin/ra-multiplex-server
Restart=always
RestartSec=5s

[Install]
WantedBy=default.target

yaymukund avatar Jan 13 '23 01:01 yaymukund