-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow 'pub serve' features to be run within a web server #18039
Comments
Added Area-Pub label. |
Removed this from the Later milestone. |
This comment was originally written by @Andersmholmgren Be nice to have a shelf handler for it |
That's the plan! |
See https://github.com/dart-lang/shelf_proxy for a good start |
This comment was originally written by @Andersmholmgren I'm using shelf_proxy which helps a lot thanks. But this is another level. When this is in place and fast incremental compilation, this is gonna be a kick ass dev loop ;) |
For the near future, this will just be a wrapper around shelf_proxy which knows how to spin up a "pub serve" instance and proxy to it. |
This comment was originally written by @Scorpiion Hi nweiz, Have you thought about code reloads? I tried to do dynamic reload of server side code before and it seem to be very hard to accomplish. The reason being the fact that the code is loaded on startup, I have yet not seen any dart server that reloads code without a restart in an effective way. That in itself, is not a huge problem, restarting most Dart servers is super fast. However, if you let that dart server spawn the "pub serve" process, then you will restart that as well, losing the quick reload in the browser. Would that not be a problem? Or do you have a solution for that? I implemented this feature for Vane (framework with support for func/podo/vane/shelf handlers) yesterday, with a wrapper around shelf_proxy as you mentioned: https://github.com/DartVoid/Vane/blob/master/lib/src/vane_client_proxy.dart However, I assume that pub serve is started and running separately. So restarting the server don't effect pub serve in any way. I think it might be a better way to start "pub serve" and the dart server separately and then proxy between them. Shelf_proxy seems to work good either way, you can try it out with Vane if you check the changelog: https://github.com/DartVoid/Vane/blob/master/CHANGELOG.md Examples of how to use shelf handlers with Vane can be found a bit down here atm, if you have some shelf handler to test: |
Robert, please see also https://code.google.com/p/dart/issues/detail?id=15860. Perhaps you'd like to star it? |
Removed Oldschool-Milestone-Later label. |
Our rough plan here is to work to improve the startup speed of "pub serve" so that it's less painful to restart it each time the code changes. Currently I don't believe there's even a way in Dart to spawn daemonized processes that will outlive their parent, which would be necessary to have the "pub serve" instance outlive the web server. |
This comment was originally written by @Scorpiion Hi Seth, yes, interesting issue, you got my star! I tried to do automatic reload of changed handlers as you suggested, earlier this summer with Vane. I scanned the files and handlers used and on incoming requests I checked if any files had changed. After that if there was changes I spawn out a new isolate and created a new instance of the requested handler using mirrors. So far it worked, but after that I could never pass that new instance back to the main isolate, that's now allowed. Probably hausner's comment is the reason, it would make some existing code "out of date". Nweiz, okay, yes I'm quite sure that is not possible, it's not supported in Go either so it feels unlikely Dart will ever be able to do that (the answer to how to do it in Go is to compile your program and then daemonize it with an external tool). Improving the startup time might be a compromise as you say. |
This issue has been moved to dart-lang/pub#948. |
Should be able to import as a package and send requests to it from within a Dart web server
The text was updated successfully, but these errors were encountered: