How to actually setup the Python Component
See original GitHub issueHi, I have a question regarding the setup of my client as I can’t really understand what actions do I need to take from the README.md.
I have an Eureka project with the following application.properties
spring.application.name=eureka-service
server.port= 8761
eureka.server.wait-time-in-ms-when-sync-empty=0
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=false
Next, I wanted to attach Zuul Gateway, in order to have a sort of API Gateway. It gets registered without any problem with the following application.properties.
server:
port: 8073
spring:
application:
name: zuul-gateway
eureka:
client:
register-with-eureka: true
fetch-registry: true
serviceUrl:
defaultZone: http://localhost:8761/eureka
zuul:
ignoredPatterns:
- /authenticate
- /delete
- /refresh
routes:
user-service:
path: /us/**
url: http://localhost:5000/
stripPrefix: true
Now comes my problem. I’m trying to register to Eureka (and, then, make it discoverable and callable also from Zuul) a really simple Flask Component, called user-service, defined with just the following lines
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
import py_eureka_client.eureka_client as eureka_client
your_rest_server_port = 5000
# The flowing code will register your server to eureka server and also start to send heartbeat every 30 seconds
eureka_client.init(eureka_server="http://localhost:8761",
app_name="user-service",
instance_port=your_rest_server_port)
app.run()
When I run all the 3 projects, though, Eureka can’t manage to find the user-service. Even if I try to use init_discovery_client, I’m still getting the same issue.
Could anyone help me on this?
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (2 by maintainers)
Top GitHub Comments
Tried both of configurations but still Eureka won’t see the Flask Component 😦
as well as
run_app(sanic_app)
is a blocked method, I think you should place it at the end of the method (aftereureka_client.init
).