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:
exec > >(tee /var/log/bootstrap.log)
apt-get --quiet --quiet update
apt-get --quiet --quiet upgrade
apt-get install --quiet --quiet postgresql
service postgresql status || true
service postgresql status || true
service postgresql status || true
service postgresql status || true
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