0

I have an application that is a interactive shell. I want this application to run as a service. To be able to access the shell while the service is running, I figured its best to start the service as a screen session that launches the application.

But this creates a problem. The service log doesn't actually show any of the output that I can see in the screen session.

How can I transmit the screen session output to the service log?

[Unit]
Description=CSGO Server
After=network.target

[Service]
Type=forking
WorkingDirectory=/home/birger/csgo-server
ExecStartPre=-/usr/bin/screen -S ${SCREEN_TITLE} -X kill
ExecStart=/usr/bin/screen -dmS ${SCREEN_TITLE} -O -l /usr/bin/bash\
 -c /home/birger/csgo-server/update-and-start
ExecStop=/usr/bin/screen -S ${SCREEN_TITLE} -p 0 -X stuff "exit^M"
Environment=SCREEN_TITLE=csgo
RemainAfterExit=false
Restart=always
RestartSec=5s
SuccessExitStatus=1

[Install]
WantedBy=default.target

Started by

systemctl --user start csgo.service

Viewing logs by

journalctl -u csgo.service

Output (is blank):

-- Logs begin at Sat 2020-02-22 14:17:45 CET, end at Mon 2021-08-16 15:06:35 CEST. --
-- No entries --

But if I attach to the screen I can see that there is actually loads of text, just not displayed in the service log.

birgersp
  • 107
  • 5
  • Why are you even doing this? srcds has the `rcon` and `steamcmd_script` features specifically so you do *not* have to pull unreliable tricks like running it in a screen session. Just run the srcds executable directly in ExecStart and enjoy having its output properly forwarded to journal! – anx Aug 31 '21 at 18:13
  • You got a point. And I guess generally speaking, there is no way to "transmit" the output from screen to the journal? – birgersp Aug 31 '21 at 18:21

0 Answers0