0

I have a python application that needs monitoring. So, I decided to deploy application using flask and monitor health with pyctuator. My app.py is

from pyctuator.pyctuator import Pyctuator

app_name = "Flask App with Pyctuator"
app = Flask(__name__)

@app.route("/")
def hello_world():
   """Function to test the functionality of the API"""
   return "Hello, world!"
Pyctuator(
   app,
   app_name,
   app_url="http://host.docker.internal:5000",
   pyctuator_endpoint_url="http://host.docker.internal:5000/pyctuator",
   registration_url="http://localhost:8080/instances"
)

if __name__ == '__main__':
   app.run(debug=True, port=8080)

I have mentioned to expose 8080 port in docker file

EXPOSE 8080

But when I deploy my application to gcp, I get this error

WARNING:root:Failed registering with boot-admin, [Errno 99] Cannot assign requested address (<class 'OSError'>)

PS: When i try to deply using uvicorn (without pyctuator), i don't see any issue of running in localhost.

CMD ["uvicorn", "service.app:app", "--port", "8080"]
kavya
  • 75
  • 1
  • 10
  • Do you need `app.run(host='0.0.0.0')`, as in [Deploying a minimal flask app in docker - server connection issues](https://stackoverflow.com/questions/30323224/deploying-a-minimal-flask-app-in-docker-server-connection-issues)? – David Maze Jun 29 '22 at 19:30
  • It is giving the same error even with ```app.run(host='0.0.0.0')``` . – kavya Jun 30 '22 at 11:54

1 Answers1

0

According to https://pypi.org/project/pyctuator/

you should run your app with your flask port (5000) rather than with your spring boot port (8080) so the correct version should be

from pyctuator.pyctuator import Pyctuator

app_name = "Flask App with Pyctuator"
app = Flask(__name__)

@app.route("/")
def hello_world():
   """Function to test the functionality of the API"""
   return "Hello, world!"
Pyctuator(
   app,
   app_name,
   app_url="http://host.docker.internal:5000",
   pyctuator_endpoint_url="http://host.docker.internal:5000/pyctuator",
   registration_url="http://localhost:8080/instances"
)

if __name__ == '__main__':
   app.run(debug=True, port=5000)
Stefano
  • 1
  • 2