1

I have a simple node.js script that accepts console commands using readline. I've set it up to run as a systemd service (on Debian 9):

[Unit]
Description=Web Game Server

[Service]
ExecStart=/usr/bin/node /var/www/index.js
Restart=always
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target

When running directly from the console with node index.js I'm able to send commands to it through the console. Is there any way to do this while it's running as a service?

user2145184
  • 123
  • 4

1 Answers1

2

Because it is now running as a systemd service, I don't think you can connect it to a console directly. You need some form of interprocess communication, such as:

  • TCP Socket server
  • UNIX socket
  • FIFO (named pipe)

The 'socat' utility can be useful to run in the console. It can connect to the service using one of the above protocols, and provide normal readline facilities to the user.

Robert Newton
  • 181
  • 1
  • 5