Infinidoge / nix-minecraft

An attempt to better support Minecraft-related content for the Nix ecosystem
MIT License
172 stars 18 forks source link

module: replace tmux with systemd socket #52

Open Misterio77 opened 6 months ago

Misterio77 commented 6 months ago

Supersedes #41.


This PR replaces tmux with a systemd stdin socket. With it, you can easily run commands like so:

echo "say Hi" > /run/minecraft/foobar.stdin

We now use this to run "stop" (or any custom command) on ExecStop, for a cleaner shutdown.

To complement extraReload, I've added more extra* options for different parts of the lifecycle: extra{Post,Pre}{Start,Stop} (preStop and postStart can run game commands, awesome!).

The tests are also expanded:

Infinidoge commented 6 months ago

As per my comment in the last PR, a prerequisite for this kind of change is that it must be configurable. It should be possible to select between tmux and socket, and tmux would remain the default for a deprecation period.

Misterio77 commented 6 months ago

Yep! Will do. Just re-created this PR to get discussion and feedback going

Silverdev2482 commented 5 months ago

I am not familiar with systemd sockets, but do they offer an interactive mode like Tmux? Although not a feature I depend on, it is a convenience I enjoy having.

Silverdev2482 commented 5 months ago

I think this is ok to put this here instead of a separate issue, could there be a way to configure the socket to be stored in the Minecraft server's directory? That would me a minor convince to me as I have to type shorter directory names.

Infinidoge commented 5 months ago

systemd sockets do not have an interactive function, which is a major reason why I am so adamant about there being a toggle for it.

Sockets are by design put in the /run runtime directory, as that is the standard place to put sockets. (Additionally, it being in /run is generally shorter than the /srv equivalent: /run/minecraft/[servername].sock vs /srv/minecraft/[servername]/server.sock (or similar))

Silverdev2482 commented 5 months ago

The reason I say I would like to be able to configure them to be there is that I'm so often cd'ed there. Although that rational makes sense.

frantisekhanzlikbl commented 3 months ago

Hi, @Misterio77, are you still working on this? I very much like the changes and am interested in using them myself. If you no longer have the time for this, would you mind me picking it up to make the socket configurable? Thanks!

Misterio77 commented 3 months ago

Hey @frantisekhanzlikbl,

Thanks for the interest, feel free to pick it up!

While I think the socket being configurable is a useful addition, I think the main blocker for this is currently making this a toggle as per @Infinidoge's comment

frantisekhanzlikbl commented 3 months ago

Ohh, sorry, I didn't express myself too well. :smile: By “making the socket configurable” I meant “making the usage of socket vs tmux configurable”. I'm currently awfully short on time, but hopefully, I'll be able to get on this in a few weeks.