27.11.2013

Systemd multiple minetest server

Hi readers!
Some time ago I wrote systemd unit file for minetest server. You can use this in Fedora 19+ ( build 0.4.8-2 ).
Later I will send mail to developers with feature request ( configuring game with systemd service file ).

Let's roll!
Files:
systemd service: minetest@.service
Example configs:
service starts minetest server with file.conf, where "file" - text after "minetest@".
Simply example. Start, show status and stop minetest server with server configs from files /etc/minetest/default.conf and /etc/minetest/ttyh.conf:
# systemctl start minetest@default $ systemctl status minetest@default minetest@ttyh.service - Minetest multiplayer server w/ default.conf server config Loaded: loaded (/usr/lib/systemd/system/minetest@.service; enabled) Active: active (running) since Wed 2013-11-27 01:43:38 MSK; 7min ago Main PID: 911 (minetestserver) CGroup: /system.slice/system-minetest.slice/minetest@default.service └─911 /usr/bin/minetestserver --config /etc/minetest/default.conf --port 30000 --map-dir /var/lib/minetest/default/ Nov 27 01:43:39 PC.localdomain minetestserver[911]: [ 0.080679]MOBF: registering new entity: ":mob_npc:npc" Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: MOD: mob_npc mod version 0.0.14 loaded Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: .__ __ __ Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: _____ |__| ____ _____/ |_ ____ _______/ |_ Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: / \| |/ \_/ __ \ __\/ __ \ / ___/\ __\ Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: | Y Y \ | | \ ___/| | \ ___/ \___ \ | | Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: |__|_| /__|___| /\___ >__| \___ >____ > |__| Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: \/ \/ \/ \/ \/ Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: World at [/var/lib/minetest/default/] Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: Server for gameid="minetest" listening on port 30000. # systemctl start minetest@ttyh $ systemctl status minetest@ttyh minetest@ttyh.service - Minetest multiplayer server w/ ttyh.conf server config Loaded: loaded (/usr/lib/systemd/system/minetest@.service; enabled) Active: active (running) since Wed 2013-11-27 01:43:38 MSK; 7min ago Main PID: 911 (minetestserver) CGroup: /system.slice/system-minetest.slice/minetest@ttyh.service └─911 /usr/bin/minetestserver --config /etc/minetest/ttyh.conf --port 30001 --map-dir /var/lib/minetest/ttyh/ Nov 27 01:43:39 PC.localdomain minetestserver[911]: [ 0.080679]MOBF: registering new entity: ":mob_npc:npc" Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: MOD: mob_npc mod version 0.0.14 loaded Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: .__ __ __ Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: _____ |__| ____ _____/ |_ ____ _______/ |_ Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: / \| |/ \_/ __ \ __\/ __ \ / ___/\ __\ Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: | Y Y \ | | \ ___/| | \ ___/ \___ \ | | Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: |__|_| /__|___| /\___ >__| \___ >____ > |__| Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: \/ \/ \/ \/ \/ Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: World at [/var/lib/minetest/ttyh/] Nov 27 01:43:39 PC.localdomain minetestserver[911]: 01:43:39: ACTION[main]: Server for gameid="minetest" listening on port 30001. # systemctl stop minetest@ttyh $ systemctl status minetest@ttyh minetest@ttyh.service - Minetest multiplayer server w/ ttyh.conf server config Loaded: loaded (/usr/lib/systemd/system/minetest@.service; enabled) Active: inactive (dead) since Wed 2013-11-27 01:54:47 MSK; 2s ago Process: 911 ExecStart=/usr/bin/minetestserver --config /etc/minetest/%i.conf --port $PORT --map-dir /var/lib/minetest/%i/ (code=killed, signal=TERM) Main PID: 911 (code=killed, signal=TERM) ... Nov 27 01:54:47 PC.localdomain systemd[1]: Stopping Minetest multiplayer server w/ ttyh.conf server config... Nov 27 01:54:47 PC.localdomain systemd[1]: Stopped Minetest multiplayer server w/ ttyh.conf server config. $
Docs: systemctl start/stop/etc. minetest@serverconfig For start new minetest server you need:
  1. /etc/sysconfig/minetest/serverconfig.conf, which contains ( actually ) string w/ port number (e.g. PORT=30000).
    See /etc/sysconfig/minetest/serverconfig.conf ( environment config )
  2. /etc/minetest/serverconfig.conf, which contains minetest server config.
    See /etc/minetest/serverconfig.conf ( server config )
Home directory ( ~ ) for minetest are /var/lib/minetest/
All mods should be installed to ~/.minetest/mods/
Generated world, etc. will be at /var/lib/minetest/serverconfig/ folder
Where "serverconfig" is name of server.
You can see this service file in Fedora works good for multiple server configurations =)
Many thanks to Jon Ciesla for sponsoring me in Fedora developers and for the great help. Sysconfig conf is his idea ;)
P.S. Sorry for bad width of css terminal (working at this)... :)

Комментариев нет: