Git Product home page Git Product logo

Comments (9)

mohammedi-haroune avatar mohammedi-haroune commented on June 22, 2024 1

Thanks for the update, but just to clarify do you mean:

Adding --ready-check-path=/healthz seems to work well for your dashboard starting OK. But that you no longer have the problem anyway, even if you drop --ready-check-path again.

?

Yes, that's it.

from jhsingle-native-proxy.

mohammedi-haroune avatar mohammedi-haroune commented on June 22, 2024 1

The bug is still happening even with --ready-check-path=/healthz

from jhsingle-native-proxy.

danlester avatar danlester commented on June 22, 2024

This idea probably makes sense, and I would like to add it as an option at some point.

However, it may be more efficient for you to use the --ready-check-path=/ready-check argument instead. This allows you to specify an alternative URL (e.g. /ready-check) that will tell jhsingle-native-proxy if the web server is ready. It is inefficient to request the main Streamlit app to do this really - maybe you can choose the URL to a smaller static asset from Streamlit that at least would indicate the Streamlit web server is ready to receive requests. This should be able to respond much quicker, and ultimately means that JupyterHub can redirect users to the dashboard sooner, so their request for the main Streamlit app can begin sooner too.

Please let me know if that helps.

from jhsingle-native-proxy.

mohammedi-haroune avatar mohammedi-haroune commented on June 22, 2024

I'll try to set --ready-check-path=/healthz for streamlit and what this what it gives

from jhsingle-native-proxy.

mohammedi-haroune avatar mohammedi-haroune commented on June 22, 2024

Unfortunately, I couldn't reproduce the bug again, even though --ready-check-path=/healthz is working for streamlit dashboards, we can't be sure it fixes the bug until reproducing it.

I'll get back whenever the bug is reproduced.

from jhsingle-native-proxy.

danlester avatar danlester commented on June 22, 2024

Thanks for the update, but just to clarify do you mean:

Adding --ready-check-path=/healthz seems to work well for your dashboard starting OK. But that you no longer have the problem anyway, even if you drop --ready-check-path again.

?

from jhsingle-native-proxy.

mohammedi-haroune avatar mohammedi-haroune commented on June 22, 2024

I reproduced the bug with the following flask app:

from flask import Flask
from time import sleep

app = Flask(__name__)

@app.route('/')
def hello_world():
    sleep(30)
    return 'Hello, World!'

and theses configurations:

c.CDSDashboardsConfig.presentation_types = ['flask']

c.VariableMixin.extra_presentation_launchers = {
    'flask': {
        'args': [
            'flask', 'run', '{--}port={port}'
        ],
        'env': {'FLASK_APP': 'app.py'},
    }
}

from jhsingle-native-proxy.

mohammedi-haroune avatar mohammedi-haroune commented on June 22, 2024

A better reproduction app:

from flask import Flask
from time import sleep, time

app = Flask(__name__)

started_at = time()
ready_after = 30

@app.route('/')
def hello_world():
    now = time()
    if now - started_at > ready_after:
        return 'Appliation ready!'
    else:
        # sleep for more that 1 seconds to make the _ready_check call fail: 
        # https://github.com/yuvipanda/simpervisor/blob/master/simpervisor/process.py#L196
        # Even status code 400 is considered as ready as per https://github.com/ideonate/jhsingle-native-proxy/blob/master/jhsingle_native_proxy/proxyhandlers.py#L707
        # return 'Application not yet ready! Please try later', 400
        sleep(5)

Why better?

The first app will always fail to start even if we increase the ready_timeout, it fails because the ready_func call is only waited for 1 second in https://github.com/yuvipanda/simpervisor/blob/master/simpervisor/process.py#L196

from jhsingle-native-proxy.

danlester avatar danlester commented on June 22, 2024

By the way, it would be great if you'd like to take a look at the experimental Flask framework:

https://cdsdashboards.readthedocs.io/en/stable/chapters/userguide/frameworks/flask.html

That should be more flexible for being able to specify a flask script to run, and it does it through gunicorn instead of the dev server. There may be some tweaks needed...

from jhsingle-native-proxy.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.