Check if port is open, but don't end job

I have the following after.sh.erb script that I’m trying to adapt for an application:

# Wait for server to start
echo "Waiting for server to open port ${port}..."
if wait_until_port_used "${host}:${port}" 240; then
  echo "Discovered server listening on port ${port}!"
else
  # Copy TOPPATH and MASTERPATH variables
  TOPPATH="/raid/$SLURM_JOB_USER.$SLURM_JOB_ID/topdir"
  MASTERPATH=$TOPCSPATH/master
  echo "Timed out waiting for server to open port ${port}!"
  # Clean up sockets
  $MASTERPATH/bin/stop
  wait 90
  pkill -P ${SCRIPT_PID}
  clean_up 1
fi
sleep 2

The issue I’m having is that it’s immediately ending the session once the script.sh.erb finishes.

In the output.log, I get:

<install output>
Generating connection YAML file...
Cleaning up...

After which it immediately ends the job. The script.sh.erb ends cleanly at the end of it and there’s no way (as script is only running the installer, not the application itself) for it to be kept in the foreground. The port is still open on the machine, but I think OOD isn’t seeing that. Is there some way to keep OOD open and connected once the port comes up?

You need to keep it in the foreground. Here’s an example of how to do that below.

1 Like