Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable loading page feature #58

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gi4no
Copy link

@gi4no gi4no commented Apr 1, 2024

This PR adds an option to disable the default loading page. With this option enabled, the request will hang until the container is ready. Then, the response will be the real response of the container, not the loading page.

In my case, I have an API server. When I call the API, the 200 HTTP response used to be the content of the HTML loading page. With this feature, the 200 response will be the actual server response.

added global config disableDefaultLoadingPage for disable all loading page
added proxy config enableDefaultLoadingPage for enable loading page if the disableDefaultLoadingPage=true
added proxy config customHttpStatusReadyChecking for have custom http status for ready check of the container

I would like to thank you of this library for their hard work and dedication. This change will be a valuable addition to the library.

Let me know what u think!

Thank you!

@gi4no
Copy link
Author

gi4no commented Apr 1, 2024

related to #57

@accforgithubtest
Copy link

Any chance this could be a workaround for issue #56 ?

@gi4no
Copy link
Author

gi4no commented Apr 12, 2024

@accforgithubtest
try this image ghcr.io/gi4no/containernursery:docker-image and let me know

add the options disableDefaultLoadingPage: true for disable default loading page

@accforgithubtest
Copy link

accforgithubtest commented Apr 16, 2024

Thanks @gi4no - I just tried it with filebrowser and it seems to help. Previously filebrowser was having the issue #56.
So this might be a potential workaround.

Any ideas for when this pr might be merged ?
I will stay on ghcr.io/gi4no/containernursery:docker-image for a while longer to test it out.

Thanks again !

@accforgithubtest
Copy link

@gi4no - Is it possible to have a global setting for disableDefaultLoadingPage: true that applies to all the applications configured in CN ?

I think that will be useful to have one global config to disable loading page for all applications in CN instead of adding the config for each and every config. Just a suggestion if it can be done. Thanks !

@gi4no
Copy link
Author

gi4no commented Apr 18, 2024

@accforgithubtest

i've add the global config, set disableDefaultLoadingPage: true on top of the yaml file.
You can try it with this image ghcr.io/gi4no/containernursery:v0.0.2

@ItsEcholot
Copy link
Owner

Thanks for this, I will try to find some time to review and merge it this weekend.

src/ConfigManager.ts Show resolved Hide resolved
Comment on lines +143 to +153
public async isContainerRunning():Promise<boolean> {
let interval:NodeJS.Timer;
return new Promise((resolve) => {
interval = setInterval(async () => {
if (this.containerRunning) {
resolve(true);
clearInterval(interval);
}
}, 250);
});
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not guaranteed to always work in my opinion. It might fail if the containers webserver needs some time to start and isn't ready yet to accept a connection.
This is the reason we have used requests & status code validations before redirecting.
What do you think?

Copy link
Author

@gi4no gi4no Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use the containerRunning because it's set to true in the checkContainerReady method (see https://github.com/ItsEcholot/ContainerNursery/blob/main/src/ProxyHost.ts#L161), so I think it's appropriate to use it. Additionally, I've been running some tests with my container, and it works fine for me. let me know!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed this reply.
containerRunning does indeed guarantee that the container is running, but this does not guarantee that the application inside the container (in our case most likely a webserver of some sorts) has started up and is ready to accept connections.
While this might work fine for a lot of containers it is in my opinion brittle.
You would need to implement an actual request check (as we already do on the waiting page) to ensure the webserver is ready for our request.

@ItsEcholot ItsEcholot added the enhancement New feature or request label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants