I have an application that writes and reads to an interactive terminal, and when I run it via the shell, it works as expected. However, when I run it as a systemd service, it seems as though the application isn't capturing the stdout or stderr.
I have tried modifying the StandardOutput and StandardError in the service definition to journal+console
and tty
.
The service section of my systemd file looks like this :
[Service]
ExecStart=/bin/bash -c "cd /somedir && python3 myapp.py"
ExecStop=
Restart=always
RestartSec=10
StandardOutput=tty
StandardError=tty
I have also tried setting TTYPath=/dev/tty2
, but no luck.
I am running Ubuntu 16.04.
Edit: More info
When I run this app, the interactive session that it creates does not get read from/written to in the terminal where I actually run the app. It emulates its own terminal.
See link here:
http://docs.paramiko.org/en/2.4/api/channel.html#paramiko.channel.Channel.get_pty
and here:
http://docs.paramiko.org/en/2.4/api/channel.html#paramiko.channel.Channel.invoke_shell
systemctl status -l (servicename)
show? – ErikF Feb 11 '18 at 06:18ExecStart=/bin/echo "Hello"
to exclude problems with themyapp.py
application. Just tested on a Ubuntu 16.04 VM andTTYPath=tty2
. Saw that thegetty@tty2
service is only activated when you switch to it. So defined a dependencyRequires=getty@tty2.service
, now it seems to work but the first output of executing the service is not logged. – Thomas Feb 11 '18 at 08:59