I'm running Ray Serve to host a HTTP API of a ray remote function. Is there a better way than below to run Ray Serve in foreground (i.e not daemon mode). Code is taken pretty straight from ray serve example:
import os
import time
import ray.serve
ray.serve.init(blocking=True, http_host="0.0.0.0", ray_init_kwargs={
'webui_host': '0.0.0.0',
'redis_password': os.getenv('RAY_REDIS_PASSWORD'),
})
ray.serve.create_endpoint("my_endpoint", "/echo")
def echo_v1(flask_request, response="hello from python!"):
return "1"
ray.serve.create_backend(echo_v1, "echo:v1")
ray.serve.link("my_endpoint", "echo:v1")
# Make sure the Docker container doesn't exit
while True:
time.sleep(2)
Without the last part:
# Make sure the Docker container doesn't exit
while True:
time.sleep(2)
The Docker container will immediately exit.