Help Meh. How to use systemd ubuntu server?

Post Reply
TARD
Member
Posts: 45
Joined: Thu Sep 01, 2016 23:28
GitHub: kingtard
IRC: turd
In-game: TARD

Help Meh. How to use systemd ubuntu server?

by TARD » Post

I've never used systemd and having hard time finding good tutorials. I need to know how to create a minetest service/unit, start on boot and restart on crash on ubuntu server 16.04. thank.

CuriousNoob
Member
Posts: 73
Joined: Wed Jan 27, 2016 09:43

re : systemd ubuntu server?

by CuriousNoob » Post

TARD wrote:I've never used systemd and having hard time finding good tutorials. I need to know how to create a minetest service/unit, start on boot and restart on crash on ubuntu server 16.04. thank.

Hello TARD

I'm running Mint-18-KDE which is based on Ubuntu-16.04-LTS.

There is a distinct package ''minetest-server'' which is installable via command-line apt or via the GUI Software Manager.

As you might guess, it sets up the files to be able to run a basic Minetest Server.

Code: Select all

#  :   apt content minetest-server 

/.
/etc
/etc/init.d
/etc/init.d/minetest-server
/etc/logrotate.d
/etc/logrotate.d/minetest-server
/etc/minetest
/etc/minetest/minetest.conf
/lib
/lib/systemd
/lib/systemd/system
/lib/systemd/system/minetest-server.service
/lib/systemd/system/minetest-server@.service
/usr
/usr/games
/usr/games/minetestserver
/usr/lib
/usr/lib/minetest
/usr/lib/minetest/minetestserver
/usr/share
/usr/share/doc
/usr/share/doc/minetest-server
/usr/share/doc/minetest-server/changelog.Debian.gz
/usr/share/doc/minetest-server/copyright
/usr/share/doc/minetest-server/README.Debian
/usr/share/man
/usr/share/man/man6

I believe it sets it up automatically on install, but, if not, I believe the systemd stuff is easily triggered using (as root or sudo) the command-line utility ''systemctl'' which is actually quite simple and logical to use for this.

Code: Select all

#  :   systemctl enable minetest-server

#  :   systemctl start minetest-server

The ''systemctl enable'' step adds a symlink in /etc :

/etc/systemd/system/multi-user.target.wants/minetest-server.service -> /lib/systemd/system/minetest-server.service

Code: Select all

#  :   cat /lib/systemd/system/minetest-server.service

[Unit]
Description=Minetest multiplayer server minetest.conf server config
Documentation=man:minetestserver(6)
After=network.target

[Service]
Restart=on-failure
User=Debian-minetest
Group=games
ExecStart=/usr/lib/minetest/minetestserver --config /etc/minetest/minetest.conf --logfile /var/log/minetest/minetest.log

[Install]
WantedBy=multi-user.target


If it's any consolation, I think Ubuntu-16's ''systemctl'' is orders-of-magnitude better than 14's ''upstart'' --- I went from Fedora-19 to Mint-17 (based on Ubuntu-14).

I've tried to explain to people IRL that going from one Linux distro to another can sometimes be thought of like moving from, say, Brazil to Spain --- core similarities in language and similarities in culture, but enough significant differences that you struggle and fall-foul to all sorts of Gotchas!

Anyway, attention to task...

Obviously you'll need to check the configuration --- the listened-on port-number and stuff like that, plus all the issues of firewalls and whatever else is network-relevant --- the defaults may or may not suit your use-case.

But remember, I'm no systemd/systemctl expert --- merely another long-suffering Linux-user who's stumbled a little further down the path on this one --- so please don't experiment if you're not willing to risk breaking your system.

Hopefully others more expert will chip-in to confirm and clarify.

Hope that helps.

.

TARD
Member
Posts: 45
Joined: Thu Sep 01, 2016 23:28
GitHub: kingtard
IRC: turd
In-game: TARD

Re: Help Meh. How to use systemd ubuntu server?

by TARD » Post

I did apt-get minetest-server, Repo outdated 4.13, but it worked and started on boot. So I changed the directory to my 4.15 dev build, that worked, the .minetest.conf file worked but it's not detecting everything below my /world folder. player files, the map or anything. I've tried moving these folders around with no luck. I'll update this post if I figure it out. I was very tired when doing this stuff so maybe that's what went wrong.
ExecStart=/minetest/bin/./minetestserver --config /etc/minetest/minetest.conf --logfile /var/log/minetest/minetest.log

CuriousNoob
Member
Posts: 73
Joined: Wed Jan 27, 2016 09:43

Re: Help Meh. How to use systemd ubuntu server?

by CuriousNoob » Post

TARD wrote:I did apt-get minetest-server, Repo outdated 4.13, but it worked and started on boot. So I changed the directory to my 4.15 dev build, that worked, the .minetest.conf file worked but it's not detecting everything below my /world folder. player files, the map or anything. I've tried moving these folders around with no luck. I'll update this post if I figure it out. I was very tired when doing this stuff so maybe that's what went wrong.
ExecStart=/minetest/bin/./minetestserver --config /etc/minetest/minetest.conf --logfile /var/log/minetest/minetest.log

Eeeyyukkk! Oops, yes, you're right, the old version 0.4.13, checked mine and it's the same --- and that's even with me using the minetestdevs ppa repository.

Quick StartPage search has not immediately thrown back hits with a ppa for any current ''minestestserver'' dev version.

Hmm... thinks...

I know it can be built from source easily enough (after you've got all the dependencies) --- there's guides aplenty round these forums and on GitHub. I haven't tried, so I'm not sure whether the usual Linux final step of ''make install'' actually does a system-wide install of minetest and minetestserver. I'll have to test it sometime unless an expert can confirm for us.

But I know that the ''minetest'' binary can also be started with the ''--server'' flag. I think it's probably equivalent.

So, the other way might be simply to ''systemctl stop'' the server, then ''systemctl disable'' it, then duplicate the minetest-server.service file into /etc/systemd/system/ and then modify the ''ExecStart='' line in the duplicate to use the regular version 0.4.15 minetest binary, then once again enable and start the service.

Code: Select all

#  :  systemctl stop      minetest-server.service
#  :  systemctl disable   minetest-server.service
#  :  cp -av  /lib/systemd/system/minetest-server.service  /etc/systemd/system/minetest-server.service
#  :  nano    /etc/systemd/system/minetest-server.service

Code: Select all

ExecStart=/usr/bin/minetest   --server   < blah blah other flags and options >
Just an idea..?

HTH

- - -

It's probably also worth saying that using suitable flags you can specify a different world and .conf file per server.

So you could also, I believe, even have multiple .service files with different names in /etc/systemd/system/, each auto-starting a different server with a different world and different .conf each listening on a different port, remembering to ''systemctl enable'' each new named server ... soon your own personal local Minetest server farm..? ;-P

Code: Select all

/etc/systemd/system/mt-server-01-CreativeWorld.service

ExecStart=/usr/bin/minetest   --server  --world /path/to/CreativeWorld  --config /path/to/CreativeWorld.conf  --logfile /path/to/CreativeWorld.log

Code: Select all

/etc/systemd/system/mt-server-02-SurvivalWorld.service

ExecStart=/usr/bin/minetest   --server  --world /path/to/SurvivalWorld  --config /path/to/SurvivalWorld.conf  --logfile /path/to/SurvivalWorld.log

Code: Select all

/etc/systemd/system/mt-server-03-PvPWorld.service

ExecStart=/usr/bin/minetest   --server  --world /path/to/PvPWorld  --config /path/to/PvPWorld.conf  --logfile /path/to/PvPWorld.log

Code: Select all

/etc/systemd/system/mt-server-04-MonsterMobsWorld.service

ExecStart=/usr/bin/minetest   --server  --world /path/to/MonsterMobsWorld  --config /path/to/MonsterMobsWorld.conf  --logfile /path/to/MonsterMobsWorld.log
.

TARD
Member
Posts: 45
Joined: Thu Sep 01, 2016 23:28
GitHub: kingtard
IRC: turd
In-game: TARD

Re: Help Meh. How to use systemd ubuntu server?

by TARD » Post

Thank, I probably do need to try with the flag to the map file.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 18 guests