Search Postgresql Archives

Re: Service not starting on Ubuntu 15.04

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxx> wrote:
On Mon, 26 Oct 2015 11:21:23 +0000
Lasse Westh-Nielsen <lassewesth@xxxxxxxxx> 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux