0

Essentially what I am trying to understand how to do is to modify some scripts I found to run two simultaneous instances of a service on a Linux Mint machine that I had lying around.

Setting up the first instance of the service I used the instructions found here:

https://www.linode.com/docs/game-servers/host-a-terraria-server-on-your-linode

Now I am attempting to take these instructions and alter them to essentially create a second service using the same scripts..

The service will not start and stay that way, though it did prior to a full machine restart. I have placed the second .service file in the same place as the first, '/etc/systemd/system/'. Contents of the service file is below.

[Unit]
Description=server daemon for whim

[Service]
Type=forking
User=whim
KillMode=none
ExecStart=/usr/bin/screen -dmS whim /bin/bash -c "/opt/terraria/TerrariaServer.bin.x86_64 -config /opt/terraria/whimserverconfig.txt"
ExecStop=/usr/local/bin/whimd exit

[Install]
WantedBy=multi-user.target

Now the reason I restarted the machine in the first place was yet another error. During the course of the instructions here I setup a script for basic administration. It is placed in the same location as the first. '/usr/local/bin/' Contents of the file are below.

#!/usr/bin/env bash

send="`printf \"$*\r\"`"
attach='script /dev/null -qc "screen -r whim"'
inject="screen -S whim-X stuff $send"

if [ "$1" = "attach" ] ; then cmd="$attach" ; else cmd="$inject" ; fi

if [ "`stat -c '%u' /var/run/screen/S-whim/`" = "$UID" ]
then
    $cmd
else
    su - whim-c "$cmd"
fi

The problem, before the service ceased to work, was that I could never attach to the screen for the new whim.service.

So my question is this:

Did I go wrong modifying one of these two files or am I missing something even more basic?

1 Answer 1

1

You deleted the following whitespace when you changed the names, turning terraria /bin/bash into whim/bin/bash for one example. This made several parts of your service unit and script file wrong.

The whole design seems pretty rickety, running screen as a system-wide service (and the bodges that that entails) in order to run a program that demands that it be interactive as a service, but that is not your doing.

1
  • My apologies, this was actually the result of a typo I made while transcribing the contents of the file. The issue mentioned in the question remains. Sep 25, 2017 at 20:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .