1

I run two instances of PostgreSQL on a CentOS 7 server, and I'm working on converting the SysV-style init scripts to systemd units. The problem is that the PostgreSQL RPM comes with a single, non-template, service unit file.

As far as I can tell, I have to choose between a few unpleasant options:

  1. I can use the deprecated .include directive to create two customized units under /etc/systemd/system. The current service file actually advises using .include for customization, but I know the directive has been deprecated, which means it might stop working in the future.
  2. I can duplicate the unit file, but then I risk diverging when eventually the original unit files gets updated but the copied unit file doesn't.
  3. I can create a template based on the existing unit file, which means my units will either both work well or not, but they still won't get updated when the upstream unit file gets updated.

Is there a better way? This seems like a common use case, for people who want to run multiple DB servers, or multiple SSH daemons, or multiple http servers on the same machine.

2

Template units are probably the best solution. This is how the Debian package is configured – you can grab their service files from the postgres-common sources and adjust the paths where necessary. It’s true that the unit file won’t get updated automatically along with upstream, but I’m afraid I don’t see a way around that. Perhaps the next major release will ship native template units?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.