python注册到eureka,,由于python提供
python注册到eureka,,由于python提供
由于python提供的服务没有加入到注册中心,没有办法实现高可用
现将python加入到注册中心实现高可用
以下是基础样例,具体功能待完善
# coding:utf-8import tornado.httpserverimport tornado.ioloopimport tornado.optionsfrom tornado.web import RequestHandlerimport py_eureka_client.eureka_client as eureka_clientfrom tornado.options import define, optionsdefine("port", default=8085, help="run on the given port", type=int)class IndexHandler(RequestHandler): def get(self): username = self.get_argument(‘username‘, ‘Hello‘) self.write(username + ‘, Administrator User!‘)#restfulAPI功能实现在这里class TestHandler(RequestHandler): def get(self): self.write("hello world welcome to you")def eurekaclient(): tornado.options.parse_command_line() # 注册eureka服务 eureka_client.init_registry_client(eureka_server="http://localhost:8091/eureka/", app_name="python-test", instance_port=8085) #提供外部调用的接口 app = tornado.web.Application(handlers=[(r"/", IndexHandler), (r"/test", TestHandler)]) http_server = tornado.httpserver.HTTPServer(app) http_server.listen(options.port) tornado.ioloop.IOLoop.instance().start() print("eureka exec")if __name__ == "__main__": eurekaclient()
#参考
#https://blog.csdn.net/xc_zhou/article/details/80637714
#https://pypi.org/project/py-eureka-client/
python注册到eureka
相关内容
- python小游戏开发关于pygame库的安装,pythonpygame,---恢复内
- python ——钟表,,1、表盘 1 fro
- 图像标注工具labelImg安装方法(win7+Python3.5+Qt5),labe
- 关于python使用requests依赖包时出现版本不匹配的警告问
- Python3基础 dict keys+values 循环打印字典中的所有键和值,
- Windows下 Python Selenium PhantomJS 抓取网页并截图,,安装P
- Mac Sublime Text 3 配置Python环境及安装插件,sublimepython,一
- python模块之导入包及模块发布,python模块,1.导入包(不
- python3之面向对象编程理解,,面向对象主要有三个特
- Linux 安装python3.7.0,linuxpython3.7.0,我这里使用的时cen
评论关闭