in reply to Backgrounding (daemonizing?) a Net::server
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.
|
|---|