inetd service replaced by systemd magic

Here is a service I used to have configured within inetd:
9999           stream  tcp     nowait  approx  /usr/sbin/approx /usr/sbin/approx
Now, let’s replace this with systemd form.

We need to define a listening socket and an associated service.

We create the socket description file: /etc/systemd/system/approx.socket

[Unit]
Description=caching proxy server for Debian archive files

[Socket]
ListenStream=9999
Accept=yes

[Install]
WantedBy=sockets.target

Then, the associated service: /etc/systemd/system/approx.service

[Unit]
Description=caching proxy server for Debian archive files

[Service]
ExecStart=-/usr/sbin/approx
StandardInput=socket

Finaly, we enable the socket and service

sudo systemctl enable approx.socket
sudo systemctl start approx.socket

We can verify the whole thing works:

systemctl status approx.socket
● approx.socket - caching proxy server for Debian archive files
Loaded: loaded (/etc/systemd/system/approx.socket; enabled; vendor preset: enabled)
Active: active (listening) since mar 2015-08-18 09:04:13 CEST; 3 days ago
Listen: [::]:9999 (Stream)
Accepted: 83; Connected: 0

That’s it folks !

References: http://puyb.net/2012/12/replace-xinetd-with-systemd/

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *