Page MenuHomeSolus

Updating postgresql to 9.6.3, adding systemd unit service.
ClosedPublic

Authored by RexMorgan on May 17 2017, 8:51 AM.
Tags
None
Referenced Files
F11002558: D124.diff
Mon, Jul 31, 1:44 AM
F11001572: D124.id221.diff
Sun, Jul 30, 9:47 AM
F10999981: D124.diff
Sat, Jul 29, 12:08 AM
F10991531: D124.diff
Tue, Jul 25, 2:15 AM
F10988739: D124.diff
Mon, Jul 24, 12:24 PM
F10986408: D124.diff
Mon, Jul 24, 1:12 AM
F10943203: D124.id281.diff
Fri, Jul 14, 5:02 PM
F10824480: D124.id221.diff
Jun 3 2023, 2:09 PM
Subscribers

Details

Summary

I've upgraded postgresql to the latest version. I've also created the systemd unit service file to start/stop/reload postgres using systemd. It's started by a script which checks to see if the /var/db/pgsql/data folder is empty, if it is, it calls initdb to initialize the database and get your default config files setup.

I started with the service file defined in postgres' docs. I updated the ExecStart to call out to postgresql.sh, since the service was setup as Type=notify, I had to add a NotifyAccess=all to that it would allow any pid to send the notification to systemd. This seemed to work ok for starting, but reloading/stopping seemed to be sending the kill signals to the wrong pid. I attempted to fix that by defining a PIDFile and pointing it to the pid file /var/db/pgsql/data/postmaster.pid that postgres uses, but it didn't help. I ended up changing this to be a forking service and use pg_ctl to control everything. That seemed to do the trick, Start/Stop/Reload all work without any errors. If you do attempt to mess with getting the Type=notify working, be sure you compile postgres with the --with-systemd option.

All of this is to say that the unit file is going against the sample service file and method. That stems from the use of the script to start postgres so we can determine if we should run initdb first, instead of starting it directly, like the sample service file.

I believe this fixes T648

Test Plan

I've tested this by doing the following steps.

  1. make the package
  2. install the package (before doing this, I'd ensure the logs and data folders were removed by running sudo rm -rf /var/db/pgsql /var/log/pgsql, but that's only because I was constantly removing/installing the package)
  3. start postgres by running sudo systemctl start postgresql
  4. ensuring it has started by checking sudo systemctl status postgresql -l
  5. installing pgadmin3 and connecting to localhost:5432
  6. I was also able to run a mix ecto.create in a phoenix project and the database was created properly in postgres
  7. stopping/reloading postgres with sudo systemctl [stop|reload] postgresql

Diff Detail

Repository
R2469 postgresql
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I've updated this to use the ExecStartPre to call initdb, based on ikey's mariadb package.

This makes things super easy and lets us do Type=notify which is the way postgres recommends you start up postgres with systemd. I'm much more confident with this, now.

ikey added a subscriber: ikey.

LGTM

This revision is now accepted and ready to land.May 21 2017, 4:24 PM

Next time please confine your commit message column limit to 80 :)

This revision was automatically updated to reflect the committed changes.