@@ -184,5 +184,35 @@ COPY docker-entrypoint.sh /usr/local/bin/
184
184
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
185
185
ENTRYPOINT ["docker-entrypoint.sh" ]
186
186
187
+ # We set the default STOPSIGNAL to SIGINT, which corresponds to what PostgreSQL
188
+ # calls "Fast Shutdown mode" wherein new connections are disallowed and any
189
+ # in-progress transactions are aborted, allowing PostgreSQL to stop cleanly and
190
+ # flush tables to disk, which is the best compromise available to avoid data
191
+ # corruption.
192
+ #
193
+ # Users who know their applications do not keep open long-lived idle connections
194
+ # may way to use a value of SIGTERM instead, which corresponds to "Smart
195
+ # Shutdown mode" in which any existing sessions are allowed to finish and the
196
+ # server stops when all sessions are terminated.
197
+ #
198
+ # See https://www.postgresql.org/docs/12/server-shutdown.html for more details
199
+ # about available PostgreSQL server shutdown signals.
200
+ #
201
+ # See also https://www.postgresql.org/docs/12/server-start.html for further
202
+ # justification of this as the default value, namely that the example (and
203
+ # shipped) systemd service files use the "Fast Shutdown mode" for service
204
+ # termination.
205
+ #
206
+ STOPSIGNAL SIGINT
207
+ #
208
+ # An additional setting that is recommended for all users regardless of this
209
+ # value is the runtime "--stop-timeout" (or your orchestrator/runtime's
210
+ # equivalent) for controlling how long to wait between sending the defined
211
+ # STOPSIGNAL and sending SIGKILL (which is likely to cause data corruption).
212
+ #
213
+ # The default in most runtimes (such as Docker) is 10 seconds, and the
214
+ # documentation at https://www.postgresql.org/docs/12/server-start.html notes
215
+ # that even 90 seconds may not be long enough in many instances.
216
+
187
217
EXPOSE 5432
188
218
CMD ["postgres" ]
0 commit comments