Skip to content

Commit 925b34c

Browse files
committed
systemd: sd_notify support
* Makefile.am: Don't generate/install postgresql-ctl for systemd systems. * postgresql.service.in: Use Type=notify, fix Exec* statements (we don't have to use the postgresql-ctl wrapper. KillMode=mixed is needed for the master/slave process design of PostgreSQL server. Drop the PGSTARTTIMEOUT variable, which is not used now (only the TimeoutSec is used now, but see rhbz#1525477).
1 parent 889d815 commit 925b34c

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

Makefile.am

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ DISTCHECK_CONFIGURE_FLAGS = \
4343
SUBDIRS = . tests
4444

4545
bin_SCRIPTS = $(setup)
46-
libexec_SCRIPTS = $(ctl) $(checkdb)
46+
libexec_SCRIPTS = $(checkdb)
4747

4848
legacyscriptsdir = $(systemdlegacyscriptsdir)/$(NAME_SERVICE)
4949

@@ -52,7 +52,8 @@ noinst_DATA =
5252
# TODO: Ideally, 'make distcheck' should check every file we generate.
5353
if WANT_SYSVINIT
5454
noinst_DATA += $(initscript)
55-
GENERATED_FILES += $(initscript)
55+
libexec_SCRIPTS += $(ctl)
56+
GENERATED_FILES += $(initscript) $(ctl)
5657
else
5758
systemdunits_DATA = $(service) $(serviceat)
5859
legacyscripts_SCRIPTS = initdb upgrade

NEWS

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22

3+
New in 8.0 version:
4+
5+
* PostgreSQL on systems with systemd are now configured with
6+
--with-systemd, which simplifies the start/stop handling (we can
7+
stop shipping postgresql-ctl wrapper, e.g.).
8+
9+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
311
New in 7.0 version:
412

513
* RPM macros file works with SCLs, too.

postgresql.service.in

+8-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Description=PostgreSQL database server
99
After=network.target
1010

1111
[Service]
12-
Type=forking
12+
Type=notify
1313

1414
User=postgres
1515
Group=postgres
@@ -26,20 +26,16 @@ OOMScoreAdjust=-1000
2626
Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
2727
Environment=PG_OOM_ADJUST_VALUE=0
2828

29-
# Maximum number of seconds pg_ctl will wait for postgres to start. Note that
30-
# PGSTARTTIMEOUT should be less than TimeoutSec value.
31-
Environment=PGSTARTTIMEOUT=270
32-
3329
@PGDATA_ENVIRONMENT@
3430

3531
ExecStartPre=@libexecdir@/postgresql-check-db-dir %N
36-
37-
# Use convenient postgresql-ctl wrapper instead of directly pg_ctl. See the
38-
# postgresql-ctl file itself for more info.
39-
40-
ExecStart=@libexecdir@/postgresql-ctl start -D ${PGDATA} -s -w -t ${PGSTARTTIMEOUT}
41-
ExecStop=@libexecdir@/postgresql-ctl stop -D ${PGDATA} -s -m fast
42-
ExecReload=@libexecdir@/postgresql-ctl reload -D ${PGDATA} -s
32+
# Even though the $PGDATA variable is exported (postmaster would accept that)
33+
# use the -D option here so PGDATA content is printed by /bin/ps and by
34+
# 'systemctl status'.
35+
ExecStart=@bindir@/postmaster -D ${PGDATA}
36+
ExecReload=/bin/kill -HUP $MAINPID
37+
KillMode=mixed
38+
KillSignal=SIGINT
4339

4440
# Give a reasonable amount of time for the server to start up/shut down.
4541
# Ideally, the timeout for starting PostgreSQL server should be handled more

0 commit comments

Comments
 (0)