Re: Service not starting on Ubuntu 15.04

From: Lasse Westh-Nielsen <lassewesth(at)gmail(dot)com>
To: Bill Moran <wmoran(at)potentialtech(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Service not starting on Ubuntu 15.04
Date: 2015-10-26 13:53:59
Message-ID: CAFyxdeQGT1xyHRPyoZpsL1yxK-8UHoHAn7oseGxN0AEQAcbfgA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bill,

Thanks for your help. But I have already tried with a variant that gives
the postgres service time to do what it needs to do:

#!/bin/bash -eux

exec > >(tee /var/log/bootstrap.log)
exec 2>&1

apt-get --quiet --quiet update
apt-get --quiet --quiet upgrade

apt-get install --quiet --quiet postgresql

service postgresql status || true
sleep 10
service postgresql stop
service postgresql status || true
sleep 10
service postgresql start
service postgresql status || true
sleep 10
service postgresql status || true
pstree

sudo -u postgres psql -c "CREATE USER foo WITH PASSWORD 'foo';"

So, output from that:
- service starts normally, i.e. first call to status says the service is
up.
- sleep-then-stop: now calling status says it has stopped.
- sleep-more-then-start: status reports service is up again
- even-more-sleep: status says service is still up
- however, that last call to pstree finds no trace of postgres

Sleeping 10 seconds came from me running these start and stop commands from
command line, where response time seems to be 2-3 seconds for start,
meaning 10 seconds should be plenty (and start seems to block, why else
would it take 3 seconds).

Thanks anyway,

Lasse

On Mon, Oct 26, 2015 at 12:09 PM, Bill Moran <wmoran(at)potentialtech(dot)com>
wrote:

> On Mon, 26 Oct 2015 11:21:23 +0000
> Lasse Westh-Nielsen <lassewesth(at)gmail(dot)com> wrote:
> >
> > I posted to stackoverflow about my problem upgrading from Ubuntu 14.04 to
> > Ubuntu 15.04:
> >
> http://stackoverflow.com/questions/33306475/ubuntu-15-04-postgresql-doesnt-start
> >
> > Tl;dr: postgresql service does not start properly when installed as a
> > package using cloud-init.
> >
> > And I can't figure out if I am doing something wrong, if the AMI is no
> > good, if the package has problems, ... I reckon I cannot be the first
> > person to use Postgres on Ubuntu Vivid, but I have been hammering my head
> > against the wall with this for hours.
> >
> > Any help greatly appreciated!
>
> I'm taking a shot in the dark here, but ...
>
> The symptoms you describe seem to suggest that the script is starting
> PostgreSQL asynchronously (i.e. in the background) which means that
> the CREATE command runs too quickly and the server isn't started yet.
>
> A quick way to _test_ this theory would be to put a sleep between the
> install and the CREATE commands and see if the problem goes away.
>
> If that does seem to be the problem, then a good _fix_ would be to
> find a way to foreground the startup of the server, or have some command
> that tests to ensure the server is started and blocks until it is
> before running the create command.
>
> The only point I'm unclear on is whether you've confirmed that
> Postgres actually _is_ started once the server is up (albiet without
> the CREATE statement having succeeded).
>
> --
> Bill Moran
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lasse Westh-Nielsen 2015-10-26 14:08:25 Re: Service not starting on Ubuntu 15.04
Previous Message Adrian Klaver 2015-10-26 13:42:59 Re: Service not starting on Ubuntu 15.04