Commit 87564df7 authored by Christoph Berg's avatar Christoph Berg

* systemd unit files are now installed to their proper locations.

* pg_ctlcluster: New --stdlog option to be used with --foreground that
  redirects stderr to our standard log files. Used in postgresql@.service.
parent bd5b279c
postgresql-common (159) UNRELEASED; urgency=medium
postgresql-common (159) UNRELEASED; urgency=low
* systemd unit files are now installed to their proper locations.
* pgcommon.sh: New shell function module containing get_release and
locale_gen. Used by supported-versions and testsuite; also usable by other
packages.
* pg_ctlcluster, PgCommon.pm: Fix warning on corrupt empty pid files.
* pg_ctlcluster: New --stdlog option to be used with --foreground that
redirects stderr to our standard log files. Used in postgresql@.service.
* pg_ctlcluster: use strict.
* Debconf translation updates, thanks!
+ da by Joe Dalton. (Closes: #753952)
......
postgresql-common (159) unstable; urgency=low
PostgreSQL clusters managed by postgresql-common are now systemd enabled. For
each cluster, a service "postgresql@<version>-<name>" is created that can be
started/stopped/restarted/reloaded. A parent service "postgresql" acts on
all installed (start.conf has "auto") clusters in parallel like the init.d
script used to do. /etc/init.d/postgresql can still be used, though the mode
of starting individual versions ("/e/i/p start 9.3") no longer works.
pg_ctlcluster can be used to control clusters, but for start and restart the
operation via systemd (using systemctl or the init.d script) is preferred, or
else the clusters will not run in cgroups. (Unfortunately this requires
root.)
If the system is not running systemd, nothing changes.
-- Christoph Berg <myon@debian.org> Fri, 18 Jul 2014 23:52:09 +0300
postgresql-common (158) experimental; urgency=medium
This postgresql-common release introduces several changes in the defaults
......
......@@ -14,10 +14,9 @@ DEFAULT_VER := $(lastword $(SUPPORTED_VERSIONS))
%:
dh "$@"
version_info:
override_dh_auto_configure:
@echo "### Building postgresql-common flavor $(FLAVOR)"
@echo "### Supported PostgreSQL versions: $(SUPPORTED_VERSIONS) (default version: $(DEFAULT_VER))"
build build-arch build-indep: version_info
override_dh_install:
dh_install
......@@ -28,6 +27,7 @@ endif
override_dh_installinit:
dh_installinit --name=postgresql -u'defaults 19 21' -r
$(MAKE) -C systemd install DESTDIR=$(CURDIR)/debian/postgresql-common
override_dh_gencontrol:
dh_gencontrol -ppostgresql-server-dev-all -- -Vserver-dev-all-depends="$(foreach v,$(SUPPORTED_VERSIONS),postgresql-server-dev-$v,)"
......
......@@ -31,6 +31,7 @@ my (@postmaster_auxoptions, @pg_ctl_opts_from_cli);
my (%postgresql_conf, %info);
my $mode = 'smart'; # default shutdown mode
my $foreground = 0; # don't daemonize, use postgres instead of pg_ctl
my $stdlog = 0; # when run in foreground, still log to the default logfile
# Check for known broken configurations of this cluster
sub check_valid_config {
......@@ -174,6 +175,10 @@ sub start {
($postmaster_opts) = $postmaster_opts =~ /(.*)/; # untaint
if ($foreground) {
if ($stdlog and $info{'logfile'}) {
dup2(POSIX::open($info{logfile}, POSIX::O_WRONLY|POSIX::O_APPEND), 1);
dup2(POSIX::open($info{logfile}, POSIX::O_WRONLY|POSIX::O_APPEND), 2);
}
my $postgres = get_program_path 'postgres', $version;
exec '/bin/sh', '-c', "exec $postgres $postmaster_opts" or
error "Executing $postgres failed: $!"
......@@ -320,6 +325,7 @@ exit 1 unless GetOptions ('o|options=s' => \@postmaster_auxoptions,
'f|force' => \$force,
'm|mode=s' => \$mode,
'foreground' => \$foreground,
'stdlog' => \$stdlog,
);
if ($mode =~ /^(s(mart)?|f(ast)?|i(mmediate)?)$/) {
......@@ -526,6 +532,11 @@ See pg_ctl(1) for documentation.
Start B<postgres> in foreground, without daemonizing via B<pg_ctl>.
=item B<--stdlog>
When B<--foreground> is in use, redirect stderr to the standard logfile in
C</var/log/postgresql/>. (Default when not run in foreground.)
=item B<-o>|B<--options> I<option>
Pass given I<option> as command line option to the C<postgres> process. It is
......
......@@ -3,7 +3,9 @@ systemd unit files for PostgreSQL on Debian/Ubuntu
Each cluster is run as a separate service, called postgresql@version/name.
As systemd prefers processes to not daemonize, pg_ctlcluster is invoked with
--foreground. (Currently, logging goes to systemd's journal.)
--foreground. Logging still goes to /var/log/postgresql. (If you prefer the
systemd journal, remove --stdlog from ExecStart postgresql@.service, or
configure the logging_collector.)
There is a parent service called postgresql.service, that starts/stops/restarts/
reloads all individual services that are configured as "auto" in
......@@ -13,6 +15,4 @@ The link between start.conf and postgresql.service is established by
postgresql-generator, which creates symlinks in
/var/run/systemd/generator/postgresql.service.wants/.
For now, the unit files are only provided as examples.
-- Christoph Berg <myon@debian.org> Tue, 20 May 2014 11:05:21 +0200
-- Christoph Berg <myon@debian.org> Fri, 18 Jul 2014 23:52:09 +0300
......@@ -10,12 +10,19 @@ PartOf=postgresql.service
ReloadPropagatedFrom=postgresql.service
[Service]
ExecStart=@/usr/bin/pg_ctlcluster postgresql@%i --foreground %i start
# @: use "postgresql@%i" as process name
ExecStart=@/usr/bin/pg_ctlcluster postgresql@%i --foreground --stdlog %i start
ExecStop=/usr/bin/pg_ctlcluster -m fast %i stop
ExecReload=/usr/bin/pg_ctlcluster %i reload
PIDFile=/var/run/postgresql/%i.pid
#Restart=on-failure
SyslogIdentifier=postgresql@%i
# restarting automatically will prevent "pg_ctlcluster ... stop" from working,
# so we disable it here. Also, the postmaster will restart by itself on most
# problems anyway, so it is questionable if one wants to enable external
# automatic restarts.
#Restart=on-failure
# (This should make pg_ctlcluster stop work, but doesn't:)
#RestartPreventExitStatus=SIGINT SIGTERM
[Install]
WantedBy=multi-user.target
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment