hey. i habe a question regarding starting a bento ...
# ask-for-help
c
hey. i habe a question regarding starting a bento with the serve() comand with the latest release version i want to do the following steps, however i am struggling with the check if the server is already alive. my current code is somehow like this:
Copy code
from bentoml import serve

server = serve(<my-bento-tag>) # start http server
server.start()

#wait until server is ready
# --> no idea what to call here, there is no server.wait_until_ready()


#finally close server
server.stop()
can somebody help?
j
I dont think
serve
is suppose to be used for any production use case. Can you share what is your use case?
c
i try to setup a POC. I fetch the an active bento ID from a Rest Service. If the ID changes, i need to kill the currently running bento service and restart it with the new bento-tag. unfortunately i can only run a bento local on my windows PC without the possibility to build a container or communicate to cloud.
j
I would suggest you to use the
cli
instead
c
so put everything into a bat-file, or is there a nicer way?
j
you can use
subprocess
to start the server if you prefer to work on python file
c
alright, i will check this out. thank you very much for your quick responses! 🙂
j
i.e.
Copy code
import subprocess

command = ["bentoml", "serve", "mybento:latest"]
result = subprocess.run(command, check=True, text=True, capture_output=True)
👍 1
c
when starting with the cli, was is the best way to check if the bento-service is ready? i would need that input if i want to switch the current service from localhost:8088 to localhost:8089 without downtime 😄
j
you can ping the
/readyz
endpoint
c
alright, thanks!