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

Allow 'pub serve' features to be run within a web server #18039

Closed
kevmoo opened this issue Apr 4, 2014 · 14 comments
Closed

Allow 'pub serve' features to be run within a web server #18039

kevmoo opened this issue Apr 4, 2014 · 14 comments
Assignees
Labels
type-enhancement A request for a change that isn't a bug

Comments

@kevmoo
Copy link
Member

kevmoo commented Apr 4, 2014

Should be able to import as a package and send requests to it from within a Dart web server

@munificent
Copy link
Member

Added Area-Pub label.

@nex3
Copy link
Member

nex3 commented Jul 2, 2014

Set owner to @nex3.
Added Started label.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@DartBot
Copy link

DartBot commented Jul 29, 2014

This comment was originally written by @Andersmholmgren


Be nice to have a shelf handler for it

@nex3
Copy link
Member

nex3 commented Jul 29, 2014

That's the plan!

@kevmoo
Copy link
Member Author

kevmoo commented Jul 29, 2014

See https://github.com/dart-lang/shelf_proxy for a good start

@DartBot
Copy link

DartBot commented Jul 29, 2014

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 ;)

@nex3
Copy link
Member

nex3 commented Jul 29, 2014

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.

@DartBot
Copy link

DartBot commented Aug 2, 2014

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:
Scorpiion/vane#1

@sethladd
Copy link
Contributor

sethladd commented Aug 3, 2014

Robert, please see also https://code.google.com/p/dart/issues/detail?id=15860. Perhaps you'd like to star it?

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@nex3
Copy link
Member

nex3 commented Aug 4, 2014

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.

@DartBot
Copy link

DartBot commented Aug 18, 2014

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.

@DartBot
Copy link

DartBot commented Jun 5, 2015

This issue has been moved to dart-lang/pub#948.

@DartBot DartBot closed this as completed Jun 5, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants