Systemd + Tshock + Docker
I've been diving pretty head long into running services with docker. I've ported someone's mineos and patched it to run in docker with a custom set of users. I have factorio server running. Even openhab running my meager home automation setup. Its the easiest way to run an application and not worry about system depaendancies.
Most of the time its pretty straight forward. docker run, walk away.
Tshock/Terraria gave me a bunch of trouble. It requires a working stdin, which none of my other daemonized processes do.
A bunch of digging and trial and error, I found out about the tty functionality for services. Which worked perfectly, but once I first logged in, it was causing my server to beep endlessly. I suspect tshock was sending terminal control codes.
Did a bit more reading. Found out you can have input from a tty, but output to the journal as normal. SUCCESS!
So for people like me that want to run tshock this way, here's my systemd service file:
[Unit]Description=terrariaAfter=docker.serviceRequires=docker.service[Service]TimeoutStartSec=0Restart=always# needed because tshock crashes when no stdinStandardInput=tty# Hijack tty11 for this purposeTTYPath=/dev/tty11# all output should stay in the journal thoughStandardOutput=journalExecStartPre=-/usr/bin/docker stop terrariaExecStartPre=-/usr/bin/docker rm terrariaExecStop=/usr/bin/docker stop terrariaExecStart=/usr/bin/docker run --rm -it \-p 7777:7777 \-v /storage/games/terraria/world:/world \--name terraria \ryshe/terraria:latest \-autocreate 3 \-world /world/Lg-Normal-17-02.wld[Install]WantedBy=multi-user.target