NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

This is the most Important Thing to do in this Setup.



Utilizing systemd to create a Minecraft server that can start on demand and stop when it has no player

Written by Solene on 20 August 2022. Tags: #minecraft #nixos #systemd #automation





Introduction to SS

Sometimes it seems like I have specific needs I have to tackle on my own. Today, I wanted to set up a local Minecraft server running on my personal computer and only when someone needs it. Instead of running a massive Java server, a Minecraft server would be started when a user connects and would stop once no player remains.



However after looking deeper into the subject it appears that I'm not the only one who requires this.



on-demand Minecraft: a project to automatically start a remote cloud server for whitelisted players



minecraft-server-hibernation: a wrapper that starts and stop a Minecraft server upon condition



In general I don't want to rely on third party tools, so I found an alternative to do this by using systemd.



Even better, keep in mind that this technique can work with any daemon provided you are able to programmatically obtain the information about whether to allow it running or stop. I am using Minecraft in this instance. The server's stop is determined by the fetch performed by the player via the rcon (a remote administration protocol).





The setup SS

To illustrate the dependencies, I made an easy graph. There are a lot of systemd components that go into this.



The most important part of this setup is the usage of the systemd proxyifier. It's an application that accepts a connection via TCP, relays it to another socket, and then allows you to do other things like start a server and wait until it's fully operational. This is the key of this configuration, without it, this wouldn't be achieved.



Basically, listen-minecraft.socket listens on the public TCP port and runs listen-minecraft.service upon connection. This service needs hook-minecraft.service which is responsible for stopping or starting minecraft, but will also make listen-minecraft.service wait for the TCP port to be open so the proxifier will relay the connection to the daemon.



Then, minecraft-server.service is started alongside with stop-minecraft.timer which will regularly run stop-minecraft.service to try to stop the server if possible.
Protonamail.lol




Configuration for SS

I used NixOS to configure my on-demand Minecraft server. This can be done on any systemd-capable system. However I will provide an NixOS example so that you can easily convert it into regular systemd configuration files.





Conclusion The SS



My Website: https://protonamail.lol/
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.