Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is sleep needed after fabric call to pg_ctl restart

I'm using Fabric to initialize a postgres server. I have to add a "sleep 1" at the end of the command or the postgres server processes die without explanation or an entry in the log:

sudo('%(pgbin)s/pg_ctl -D %(pgdata)s -l /tmp/pg.log restart && sleep 1' % env, user='postgres')

That is, I see this output on the terminal:

[dbserv] Executing task 'setup_postgres'
[dbserv] run: /bin/bash -l -c "sudo -u postgres /usr/lib/postgresql/9.1/bin/pg_ctl -D /data/pg -l /tmp/pg.log restart && sleep 1"
[dbserv] out: waiting for server to shut down.... done
[dbserv] out: server stopped
[dbserv] out: server starting

Without the && sleep 1, there's nothing in /tmp/pg.log (though the file is created), and no postgres processes are running. With the sleep, everything works fine.

(And if I execute the same command directly on target machine's command line, it works fine without the sleep.)

Since it's working, it doesn't really matter, but I'm asking anyway: Does someone know what the sleep is allowing to happen and why?

like image 243
wouldnt Avatar asked Oct 07 '22 17:10

wouldnt


1 Answers

You might try also using the pty option set it to false and see if it's related to how fabric handles pseudo-ttys.

like image 121
Morgan Avatar answered Oct 10 '22 01:10

Morgan