Andrew Aylett
Andrew Aylett

Reputation: 40730

Receiving open sockets from the environment in Java

systemd supports socket activation, which means that sockets will be passed to the daemon process as open file descriptors. Is there any way to retrieve and use these sockets from Java?

Upvotes: 2

Views: 1062

Answers (1)

user207421
user207421

Reputation: 310985

Yes, this is what System.inheritedChannel() is for.

On the systemd side, you should be able to make your service file pass the socket as fd 0 (which is what Java expects) by setting StandardInput=socket.

Upvotes: 5

Related Questions