NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

This is the Main Point of this Setup



Systemd is used to create an Minecraft server to start on-demand and stop when it has no player

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





Introduction to the SS

Sometimes, I feel like I have specific use cases I need to solve alone. Today, I wanted to set up an individual Minecraft server running on my workstation and only when someone needs it. The point was that instead of having a big Java server running across the time, Minecraft server would start after a player's connection and would shut down when there was no connection from a player.



After studying the topic more, I realized that I'm not the only one that needs it.



on-demand-minecraft is a project that automatically initiates a remote cloud server for whitelisted gamers



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



As often I do, I prefer not to rely on third-party tools whenever I can find an option to implement this using only systemd.



Also, take note that this method can work with any daemon given you can programmatically get the information about whether to allow it run or stop. In this case I'm using Minecraft and the server's stop is decided by the player's connection to fetch using rcon (a remote administration protocol).





The setup SS

To illustrate the dependencies, I created a simple graph. There are a lot of components of the system that contribute to this.



The most important part of this setup is the use systemd proxyifier. It's a command that accepts a connection via TCP, relays it to another socket, and then allows you to do other things such as start the server and wait until it's fully operational. This is the key of this configuration, without it, this would not be done.



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.





Configuration for SS

I used NixOS to configure my on-demand Minecraft server. This can be done on any systemd-capable device. However, I will give you an NixOS example to make it easy to convert it into regular systemd configuration files.





Conclusion The SS


srvlst
My Website: https://srvlst.com/
     
 
what is notes.io
 

Notes is a web-based application for online 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 14 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.