The service works perfectely if I am not logged in, but if I connect with ssh and then disconnect the service gets terminated. The service belongs to the user to whom I ssh. This is my current ts3.service file:
[Unit]
Description=TeamSpeak3Server
[Service]
User=user1
Group=staff
Type=forking
WorkingDirectory=/usr/local/bin/teamspeak3-server_linux_amd64
ExecStart=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh start
ExecStop=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh stop
PIDFile=/usr/local/bin/teamspeak3-server_linux_amd64/ts3server.pid
RestartSec=5
Restart=always
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
I have already tried changeing ExecStart to
ExecStart=/usr/bin/nohup /usr/local/bin/teamspeak3-server_linux_amd64/ts3server_startscript.sh start
Other services like openvpn survive the ssh logout.
After reconnection the status of the systemd process reads:
active (exited)
while the normal status is
active (running)
Could the cause of the problem be that the script which I execute calls another script which gets killed if the shell sends sighup meassages?
Thank you for your answers.
**Edit:**
the important part of ts3server_startscript.sh are as follows:
COMMANDLINE_PARAMETERS="${2}"
D1=$(readlink -f "$0")
BINARYPATH="$(dirname "${D1}")"
cd "${BINARYPATH}"
LIBRARYPATH="$(pwd)"
BINARYNAME="ts3server"
if [ -e "$BINARYNAME" ]; then
if[ -x "$BINARYNAME" ]; then
export LD_LIBRARY_PATH="${LIBRARYPATH}:${LD_LIBARY_PATH}"
"./${BINARYNAME}" ${COMMANDLINE_PARAMETERS} > /dev/null &
PID=$!
ps -p ${PID} > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo "..."
else
echo $PID > ts3server.pid
fi
So if I interpret that correctely the server is started in the console by
"./${BINARYNAME}" ${COMMANDLINE_PARAMETERS} > /dev/null &
Asked by Beny Benz
(21 rep)
Jun 14, 2018, 01:39 PM
Last activity: Jun 14, 2018, 05:16 PM
Last activity: Jun 14, 2018, 05:16 PM