Closed wnewbery closed 6 years ago
Same problem here 😢 with systemd
I managed to stop tshock from crashing by adding the stdin and stdout options in the systemd service file:
[Unit]
Description=tshock
[Service]
Restart=always
# needed because tshock crashes when no stdin
StandardInput=tty
# Hijack tty11 for this purpose
TTYPath=/dev/tty11
# all output should stay in the journal though
StandardOutput=journal
WorkingDirectory=/home/luke/tshock/tshock
ExecStart=/usr/bin/mono /home/luke/tshock/TerrariaServer.exe -world '/home/luke/.local/share/Terraria/Worlds/Luke_Server.wld'
[Install]
WantedBy=multi-user.target
Yeah you can also give it a terminal using screen
or such as well, but at best that is a hack (and needs some more work with systemd
to make it detect status, restart, etc. correctly). I the case of /dev/ttynn
conflicts are possible, but I guess its OK if you just running one server on a system, there is 64 to go through but some things might take one dynamically.
Really though, I think TShock should not be needing a full terminal, just plain stdin
or signals would be enough. Really the only thing I care about running as a daemon is a simple graceful shutdown, which I think that config you provided is missing as well (at least on my system, I didn't appear to get a graceful shutdown with save etc. when systemd tries to stop it)
I'm really interested in the process you guys used to get a daemon setup. Currently I am trying to start Tshock with a single line of code:
sudo MONO_THREADS_PER_CPU=50 mono ~/tshock/TerrariaServer.exe -world "~/My Games/Terraria/Worlds/Ubuntu_Server.wld"
If you have any insight into how to set the server up the way you did, it would be greatly appreciated!
I'm thinking this issue is related to #1450 as it is throwing an error in Terraria.Main.startDedInputCallBack
I have made a PR for this over at the TSAPI repository - it needs testers ;)
I'd be happy to help you test this, but I'd have no idea how to implement this!
@Ihatetotank It's been a while since I did it, but I basically create a systemd service which automatically starts the server anytime my digitalocean server boots up.
First, you gotta install the mono-complete Ubuntu package with sudo apt-get install mono-complete
, which should create /usr/bin/mono
Assuming your machine also has systemd, you can just create a service file in /etc/systemd/system
called terraria.service
, resulting in /etc/systemd/system/terraria.service
and insert the following file:
[Unit]
Description=terraria
[Service]
Restart=always
# needed because tshock crashes when no stdin
StandardInput=tty
# Hijack tty11 for this purpose
TTYPath=/dev/tty11
# all output should stay in the journal though
StandardOutput=journal
WorkingDirectory=/home/luke/tshock/tshock
ExecStart=/usr/bin/mono /home/luke/tshock/TerrariaServer.exe -world '/home/luke/.local/share/Terraria/Worlds/Tektron_World.wld'
[Install]
WantedBy=multi-user.target
Then, you need to make a few modifications to the service file, make systemd aware of your service, make it auto start and then start it up:
Replace the part after the =
in WorkingDirectory=/home/luke/tshock/tshock
with where you extracted tshock + the tshock subdirectory. I extracted the tshock zip file to /home/luke/tshock/
(which contains TerrariaServer.exe) and there's a tshock subdirectory, hence /home/luke/tshock/tshock
.
Replace /home/luke/tshock/TerrariaServer.exe
with the location of your TerrariaServer.exe and /home/luke/.local/share/Terraria/Worlds/Tektron_World.wld
with the location of your world.
Run sudo systemctl daemon-reload
to make it pick up the new terraria.service
file.
Run sudo systemctl enable terraria
to make it start on bootup
Run sudo systemctl start terraria
to run it.
Run sudo systemctl status terraria
to see the status.
Hopefully, you're 💯 . I'm not too good at writing tutorials, so I hope it's clear.
Closing. Reopen if the above did not work
When running as a Linux daemon process I get this error and a crash log on every start. In my initial testing it didnt actually terminate the process and I was able to join the server. stdin will be opened to
/dev/null
in this configuration.Running just the
mono
command results in no error, so I am guessing the problem is not having a terminal, rather than no stdin / stdout.Using TShock Mintaka 4.3.24 for Terraria 1.3.5.3.