File tree 3 files changed +24
-6
lines changed
3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ New in 3.0 version
18
18
* The sysvinit support should be OK finally, sysvinit system is now
19
19
automatically detected without --with-sysvinit configure option.
20
20
21
+ * The starting timeout is now configurable via PGSTARTTIMEOUT.
22
+
21
23
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22
24
23
25
New in 2.0 version
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ PG_OOM_ADJ=-17
73
73
74
74
export PGDATA
75
75
export PGPORT
76
+ export PGSTARTTIMEOUT
76
77
77
78
lockfile=" /var/lock/subsys/${NAME} "
78
79
@@ -111,13 +112,22 @@ start()
111
112
# is already running. We should probably 'status' first and start only if
112
113
# postmaster is down. This just unnecessarily wastes time and generates
113
114
# too much (false) rush in $PGLOG.
115
+ #
116
+ # The maximum waiting time PGSTARTTIMEOUT is set to 30 second to not hold
117
+ # the system too long. See `man pg_ctl & -w option`. This is not issue in
118
+ # case of systemd.
119
+
114
120
run_cmd_as_dbadmin \
115
- " $PGENGINE /postgres ${PGPORT+-o " -p $PGPORT " } \
116
- -D ' $PGDATA ' ${PGOPTS} & " \
121
+ " @libexecdir@/postgresql-ctl start -D ${PGDATA} -s \
122
+ -w -t ${PGSTARTTIMEOUT-30} " \
117
123
" $PGLOG " " $PGLOG "
118
124
119
- # TODO: parametrize
120
- sleep 2
125
+ if test $? -ne 0; then
126
+ failure " $PSQL_START "
127
+ echo
128
+ script_result=1
129
+ return
130
+ fi
121
131
122
132
pid=` head -n 1 " $PGDATA /postmaster.pid" 2> /dev/null`
123
133
if [ " x$pid " != x ]
Original file line number Diff line number Diff line change @@ -26,18 +26,24 @@ OOMScoreAdjust=-1000
26
26
Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
27
27
Environment=PG_OOM_ADJUST_VALUE=0
28
28
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
+
29
33
@PGDATA_ENVIRONMENT@
30
34
31
35
ExecStartPre=@libexecdir@/postgresql-check-db-dir %N
32
36
33
37
# Use convenient postgresql-ctl wrapper instead of directly pg_ctl. See the
34
38
# postgresql-ctl file itself for more info.
35
39
36
- ExecStart=@libexecdir@/postgresql-ctl start -D ${PGDATA} -s -w -t 300
40
+ ExecStart=@libexecdir@/postgresql-ctl start -D ${PGDATA} -s -w -t ${PGSTARTTIMEOUT}
37
41
ExecStop=@libexecdir@/postgresql-ctl stop -D ${PGDATA} -s -m fast
38
42
ExecReload=@libexecdir@/postgresql-ctl reload -D ${PGDATA} -s
39
43
40
- # Give a reasonable amount of time for the server to start up/shut down
44
+ # Give a reasonable amount of time for the server to start up/shut down.
45
+ # Ideally, the timeout for starting PostgreSQL server should be handled more
46
+ # nicely by pg_ctl in ExecStart, so keep its timeout smaller than this value.
41
47
TimeoutSec=300
42
48
43
49
[Install]
You can’t perform that action at this time.
0 commit comments