在猎鹰中自动执行Web服务 [英] auto execute a web service in falcon

查看:113
本文介绍了在猎鹰中自动执行Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个功能,可以将我的Web服务注册到spring-eureka发现服务器,但是它会自动注销它.为了解决这个问题,我想做一个可以在几秒钟后自动执行并一次又一次注册我的服务的功能.

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.

推荐答案

我们可以制作另一个程序ping我的Web服务器的运行状况检查URL.

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()

该程序将在应用程序启动并运行后立即运行,并以100秒的时间间隔进行注册

This program will run as soon as application gets up and running and registers it in in time inteval of 100seconds

这篇关于在猎鹰中自动执行Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆