gdraheim / docker-systemctl-replacement

docker systemctl replacement - allows to deploy to systemd-controlled containers without starting an actual systemd daemon (e.g. centos7, ubuntu16)
European Union Public License 1.2
1.39k stars 399 forks source link

Generators support ? #109

Open hlobit opened 3 years ago

hlobit commented 3 years ago

Use case:

I got the same result reported on issue #77, the systemctl shows the service is running, but no postgresql process is running at all. The workaround to get the service running was to use systemctl start postgresql@11-main.

After going deeper in debian packaging of postgresql to track the issue, I discovered the generators feature of systemd.

A script at /lib/systemd/system-generators/postgresql-generator generates the service as a symlink:

/run/systemd/generator/postgresql.service.wants/postgresql@11-main.service -> /lib/systemd/system/postgresql@.service

gdraheim commented 3 years ago

Actually, the whole template and generator features of systemd is a bad approach in the world of containers. If multiple instances of a service are needed then multiple containers should be started.

Nethertheless, template units do work - that's the postgresql@.service part that you see. And the support is needed for some applications which only have the implementation of the start/stop in there.

Your workaround looks completely correct. You could flesh that out with using drop-in parts to patch the postgresql.service replacing the generator call with a direct symlink creation.

https://github.com/gdraheim/docker-systemctl-replacement/blob/master/EXTRA-CONFIGS.md

By the way, debian support is still missing in the examples which is the reason that I did miss the change. The sister project serves also as a test suite for real world services - and postgres is one of the main things that should work of course.

https://github.com/gdraheim/docker-systemctl-images

gdraheim commented 3 years ago

I have added test_318 to docker-systemctl-images and well, the setup for postgres ubuntu has a few differences.

https://github.com/gdraheim/docker-systemctl-images/blob/develop/ubuntu18-postgres.dockerfile