I use Fabric to initialize the postgres server. I have to add “sleep 1” at the end of the command or postgres server processes to die without explanation or logging:
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] Running the 'setup_postgres' task
[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 the server to finish .... done
[dbserv] out: server stopped
[dbserv] out: starting the server
Without && sleep 1the file /tmp/pg.log there is nothing (although the file was created), and no postgres processes are executed. With sleep, everything works fine.
(And if I execute the same command directly on the command line of the target computer, it works fine without sleep.)
Since it works, it doesn’t really matter, but I still ask: does anyone know what can allow sleep and why?
source
share