keijack / python-eureka-client

A eureka client written in python. Support registering your python component to Eureka Server, as well as calling remote services by pulling the the Eureka registry.
MIT License
184 stars 43 forks source link

about gunicorn #6

Closed winxblast closed 5 years ago

winxblast commented 5 years ago

兄弟,感觉你是中国的,我就直接写中文了 我在直接启动 flask 的情况下,能把 python 顺利注册到本地的注册中心。 然后在服务器上使用 gunicorn 启动 flask ,就无法正常启动应用了,错误日志在公司电脑,没法拷贝出来··· 请问能支持 gunicorn 启动么?多 worker 情况呢?

keijack commented 5 years ago

I have not tested it in gunicorn, I will give it a try and find some solution for you. And yes, I am Chinese, you can use Chinese as you wish.

winxblast commented 5 years ago

thanks now I decide to use the spring-cloud-netflix-sidecar to register python web service to the eureka

keijack commented 5 years ago

I see, sidecar is always a fallback option.

hyytt commented 5 years ago

你好,我用的是0.0.2这个版本的包,遇到一个问题,就是正式环境下,将Python服务注册到eureka上以后,开始运行一天就从eureka上掉了,但是服务没挂。后来重新安装了一下包,隔了一周又掉了,但是服务没挂。测试环境测的时候就一直在eureka上,修改日志输出也可以看到一直有发送心跳。正式环境和测试环境可能的区别就是正式环境一直有别人在掉它的接口,测试环境没有人调它的接口。想咨询一下可能会是什么问题呢

keijack commented 5 years ago

@hyytt I'm so sorry that I response so late, I want some more information, is the heartbeat success?

hyytt commented 5 years ago

你好,这个问题我们找到了,是我们自己的服务有点问题。但是有个地方还是有点疑问,就是在运行过程中如果服务已经从eureka上掉线以后,再发送心跳失败几次后是不是应该尝试重新注册呢,因为eureka上已经没有这个服务的注册信息,再不停的发送心跳已经没有意义了。我们目前是修改了此处的逻辑。

keijack commented 5 years ago

@hyytt in the latest version, it will try to register when hearbeat fails:

    def send_heart_beat(self, overridden_status=""):
        try:
            self.__try_all_eureka_server(lambda url: send_heart_beat(url, self.__instance["app"],
                                                                     self.__instance["instanceId"], self.__instance["lastDirtyTimestamp"],
                                                                     status=self.__instance["status"], overriddenstatus=overridden_status))
        except:
            _logger.exception("Error!")
            _logger.info("Cannot send heartbeat to server, try to register")
            self.register()