1

I've got a systemd service set up with the following configuration (in /etc/systemd/system/my-service.service):

[Unit]
Description=My service

[Service]
WorkingDirectory=/path/to/my/service
User=some-user
Group=some-group
Restart=on-failure
RestartSec=20 5
ExecStart=my-service-binary

[Install]
WantedBy=multi-user.target

When the program is started, it provides a command line interface to allow interaction. However, as this program is run by systemd, I can't immediately see a way to interact with the program directly. Is there some way to "connect" to the stream the program provides, while running it as a service within systemd?

Sean
  • 145
  • 5

1 Answers1

3

In man systemd.exec, you'll find that you can set StandardInput= to a value of tty, and then set TTYPath= to set a particularly TTY to connect to.

It's fairly unconventional to use systemd to run CLI apps though.

Some services may appear to run via systemd and offer a CLI, but they are really using a client/server model. For example, database servers are typically run via systemd, but you connect to them via CLI when they are running.

How the client/server interaction works is specific to each server. Usually they are communicating over a local port or socket.

You should first confirm if the service you running is designed to connect directly to a TTY or whether it actually listening a local port or socket that a CLI-based client connects to.

Mark Stosberg
  • 3,771
  • 23
  • 27
  • Thanks - I'll give that a try and see if I can get it to work. I'm unfamiliar with how TTY works so I'll first have to look at that. – Sean Mar 19 '17 at 19:58