It sounds like you're pretty sure your server will eventually start and you just want to make sure that it's ready before the client starts so that your bash script doesn't fail.

That's not so easy. How about this, make sure that your client returns a proper status to the shell based on success or failure.

#!/bin/bash SRV=/full/path/to/server SRV_ARG="-nodb -co /full/path/to/server.conf" CLT=/full/path/to/client CLT_ARG="-user=admin -p=23000" $SRV $SRV_ARG $@ & sleep 3 if ! $CLT $CLT_ARG ; then sleep 3 if ! $CLT $CLT_ARG ; then sleep 6 if ! $CLT $CLT_ARG ; then echo Server must be broken! exit 1 fi fi fi

You'll probably need to work with more than a single status from the client. Maybe you'll have RC_OK, RC_NOSVR, RC_BADARG, ... and your script will have to check for RC_NOSRV and try again.


In reply to Re: Backgrounding (daemonizing?) a Net::server by Anonymous Monk
in thread Backgrounding (daemonizing?) a Net::server by PetaMem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.