systemd: on-demand start of services like postgresql and mysql that do not yet support socket-based activation
You may use the systemd-socket-proxyd
tool to forward traffic from a local socket to MySQL or PostgreSQL with socket-activation. See systemd-socket-proxyd(8) for examples.
socket-based activation is not yet supported in PostgreSQL & MySQL.
The question is the answer. You have already found the better way, mentioned it in the question, and then stated that it has not been implemented. Oracle closed the issue saying that socket activation (really, using already-opened listening file descriptors instead of opening its own, as far as the server program is concerned) has been implemented when it has not been. MariaDB has a still-open issue. As for PostgreSQL, you are in the same boat as Christoph Berg waiting for this to be implemented.
Further reading
- Jonathan de Boyne Pollard (2016). MariaDB and MySQL with nosh. Softwares.
- David Strauss (2014-01-17). Support systemd socket activation. MDEV-5536. MariaDB.
- Harald Reindl (2011-07-21). mysql / systemd socket activation. 61948. MySQL bug tracker.
- Christoph Berg (2016-01-28). [PATCH] better systemd integration. PostgreSQL Hackers.