<div dir="ltr"><div>Hello Michael, hello devs</div><div>Don't know why upstart's finite machine ignores errors in post-start but I guess you can do following:</div><div><br></div><div>1) you can try kill postgres from post-start (or kill main, but you will need to parse output of `initctl status`)</div>

<div>2) upstart kills all processes in process group so you can run postress in background and check its status</div><div><br></div><div>
env ready=/tmp/pgsql-ready</div><div>env ready_timeout=20</div><div><br></div>pre-start<div><pre style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace">  if [ -d /var/run/postgresql ]; then
     chmod 2775 /var/run/postgresql
  else
     install -d -m 2775 -o postgres -g postgres /var/run/postgresql
  fi</pre><div>    rm -rf $ready</div><div>end script</div><div><br></div><div>main</div><div>  <span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace">postgres .. &</span></div>

<div><span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace"> pid=$!</span></div><div><span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace"><br>


</span></div><div><span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace"> for i in `seq 1 10` ; do</span></div><div><span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace">    if psql -c 'select 1' ; then</span></div>

<div><span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace">        touch $ready</span></div><div><span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace">        break</span></div>

<div><span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace">    fi</span></div>
<div><span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace"> done</span></div><div><span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace"><br>


</span></div><div><span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace"> if [ -e $ready ] ; then</span></div>
<div><span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace">    wait $pid</span></div><div><span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace"> fi</span></div>


<div>end script</div><div><br></div><div>post-start</div><div>  while [ ! -e $ready<span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace"> ] ; do</span></div><div style>
<span style="font-size:14px;font-family:'Bitstream Vera Sans Mono','Courier New',Monaco,monospace">   log "waiting.."<br></span></div>

<div>  done</div><div>end script</div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/4/16 Michael Barrett <span dir="ltr"><<a href="mailto:loki77@gmail.com" target="_blank">loki77@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, I'm working on converting my postgresql package to using upstart.  While doing so, I found that postgres takes a few moments after starting to actually start accepting connections.  I decided to use a post-start job to test whether the postgres server was up and available before letting upstart believe the service was ready.<br>

<br>
Currently my upstart job looks like this: <a href="http://dpaste.com/1060864/" target="_blank">http://dpaste.com/1060864/</a><br>
<br>
The issue I'm running into now is that whenever there is an issue with the postgres server that causes it to crash, the post-start job hangs indefinitely (as you'd expect from the loop).  I can't stop the job or restart it once I fix the issue.  The only way I've been able to fix it is to bring up postgres manually, which allows the post-start to finish.<br>

<br>
I've tried putting a maximum # of retries in the post-start script, then doing an exit 1 when it exceeds that amount, but that results in the 'start postgresql' command exiting successfully, which causes issues in other places in my application (because postgres isn't actually running).<br>

<br>
What is the suggested method for dealing with something like this?  Is there anyway to tell the post-start to terminate?  Is there any way for post-start to signal that there was an issue starting the daemon after a # of retries?  I'm sure I'm missing something key in my understanding, so any help would be appreciated.<br>

<br>
Thanks!<br>
<br>
--<br>
Michael Barrett<br>
<a href="mailto:loki77@gmail.com">loki77@gmail.com</a><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
<br>
<br>
--<br>
upstart-devel mailing list<br>
<a href="mailto:upstart-devel@lists.ubuntu.com">upstart-devel@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/upstart-devel" target="_blank">https://lists.ubuntu.com/mailman/listinfo/upstart-devel</a><br>
</font></span></blockquote></div><br></div>