问题
I have a function which registers my web-services to spring-eureka discovery server but it automatically de-registers it. to solve this problem, I thought to make a function which will automatically execute in few seconds and register my service again and again.
Please suggest what to do and if u have a better approach to encounter this problem that will be great.
回答1:
We can make another program which will ping the health check URL of my web server.
responsePythonAPI = requests.request("GET", "http://10.95.51.8:5050/health", headers=headers)
pythonAPI = True if responsePythonAPI.json()["status"]["value"] == u'200 OK' and responsePythonAPI.json()["status"]["code"] == 200 else False
if pythonAPI == True:
eureka.registerWebService()
else:
eureka.deregisterWebService()
This program will run as soon as application gets up and running and registers it in in time inteval of 100seconds
来源:https://stackoverflow.com/questions/47512483/auto-execute-a-web-service-in-falcon