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.