0

I am currently trying to build some integrations tests with Nomad.

For that I try:

nomad agent -dev -config=test.conf&
nomad run test.nomad

which of course fails, since it tries to submit the job before the server is running. The bad option would be to insert a sleep. My question is, whether there is a better way to wait until the server is up and accepts jobs.

abergmeier
  • 13,224
  • 13
  • 64
  • 120

2 Answers2

1

So a only halfway hacky solution is:

wait_for_agent() {
  while test -z $(curl -s http://127.0.0.1:4646/v1/agent/health)
  do
    sleep 1
  done
}
abergmeier
  • 13,224
  • 13
  • 64
  • 120
0

Another hack :-)

nomad agent -dev -config=test.conf && nomad run test.nomad
Greg
  • 6,571
  • 2
  • 27
  • 39