question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to actually setup the Python Component

See original GitHub issue

Hi, 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:closed
  • Created 3 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
TheGlobalistcommented, May 10, 2020

Tried both of configurations but still Eureka won’t see the Flask Component 😦

0reactions
keijackcommented, Jun 9, 2020

as well as run_app(sanic_app) is a blocked method, I think you should place it at the end of the method (after eureka_client.init).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setup and Building - Python Developer's Guide
Setup and Building# · Install git # · Get the source code# · Compile and build# · Install dependencies# · Regenerate configure #...
Read more >
Setting up a Python development environment | Google Cloud
Use the venv command to create a virtual copy of the entire Python installation. · Set your shell to use the venv paths...
Read more >
How to Use Python: Your First Steps
In this step-by-step tutorial, you'll learn the basics of how to use Python. With this knowledge, you'll be able to start coding your...
Read more >
Python Download, Installation And Python Hello World Program
In this section, we shall cover the two common ways to install Python. But before we install, we should first check if Python...
Read more >
Get Started Tutorial for Python in Visual Studio Code
Along with the Python extension, you need to install a Python interpreter. Which interpreter you use is dependent on your specific needs, but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found