Something I threw together in a few minutes. Assumes you have mono installed (i mean, it's kinda required to run the server on linux)
- Throw the .service file into
/etc/systemd/system/ - Run
systemctl enable gtmp-serverto enable running the server on startup - Run
systemctl start gtmp-serverto start the server.
You can view logs of the running server with journalctl -u gtmp-server. Additionally, you can add filters like...
--since: Show logs since the certain time (ie.--since today)- Also works with dates/times in the format:
YYYY-MM-DD HH:MM:SS(--since 2017-12-31 02:13:00)
- Also works with dates/times in the format:
-n: Show last n lines (ie.-n 50to show last 50 lines)-f: Show last few lines, and monitor for new lines (kind of liketail -f)-b: Show logs since last system boot- You can use
journalctl --list-bootsto list boots, then do-b [boot number]to show a logs on that specific boot of the server. For example, for boot number -1, I would do:journalctl -u gtmp-server -b -1.
- You can use
- Does not require using external services
- Works with systemd's VM management system (machinectl,
systemctl --machine) - Uses less disk space due to less dependencies (but not that much, really)
I also included a second configuration that sandboxes the server a bit more from the rest of the system. This is done using systemd dynamic users, introduced in systemd 235 (released October 2017). Enabling dynamic users has the following side effects from the options it implies:
ProtectSystem=strict- mounts/usrand/bootread only for the serviceProtectHome=read-only- mounts/home,/root, and/run/userread-only for the service- Set this to true to completely block reads on these directories
PrivateTmp=true- Gives the service it's own/tmpand/var/tmpdirectories, separate from the rest of the systemRemoveIPC=true- Removes IPC objects after the service dies (Shared memory, message queues, and semaphores)
You will need to make sure to set the StateDirectory value to the path to the server, or else the server will not be able to write to it's own directory. For more information on DynamicUser, take a look at this article.
👍 for not requiring something as obscure as PHP, and using the built in init.d!