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

Use webdev as a daemon #55

Closed
Balint66 opened this issue Jan 23, 2023 · 4 comments
Closed

Use webdev as a daemon #55

Balint66 opened this issue Jan 23, 2023 · 4 comments

Comments

@Balint66
Copy link

As mentioned in #49 there is other ways of using the webdev package. I had quick a look at the source code of webdev and there is an "undocumented" command line option to use it as a daemon, just like someone can use flutter as described in the documentation.

pro:

  • If it's implemented with daemon, then jaspr shouldn't have webdev as a direct dependency (the user can activate it globally).
  • Already existing code could be reused, as it expects an executable/process right now.
  • The started process could be reused.

con:

  • Jaspr should implement it's own daemon, so the child process could be reused.
  • It looks like the daemon is only used for building, but not serving.

Maybe a mixed implementation could be used:

  • For building, jaspr could create it's own daemon based on flutter's and webdev's
  • For serving, it could call to webdev as a package

I wanted to create this issue to signal my finding, and start a conversation. Eventually I want to work on this and the mentioned issue's implementation, and I'm curious if creating such feature would be any help. 😄

@schultek
Copy link
Owner

Thanks for looking into this. Maybe we can combine boach approaches by using webdev as a package and using the deamon api.

@schultek
Copy link
Owner

When I run webdev as daemon, it serves the page just as the serve command does. The only difference is that the console output is in json.

@Balint66
Copy link
Author

Yes, from the outside it does look like that it does nothing but the same as the serve but with json output.
But in the inside, it does more:

  1. Starts the daemon with the daemon domain, so in the beginning, only those commands, and the preregistered ones, like restart, can be executed.
  2. Validates the app, if it can be launched.
  3. Starts the DevWorkflow. This is where it starts the serving.
  4. Adds the app domain.
  5. Waits for the daemon to exit.

What's different, is that you can give it commands via jsonRPC on stdin. So, you can restart the app, stop the daemon, get it's version., and it will respond on stdout. Most things are documented on the flutter page, how one should attach to the process, the communication workflow.

I tried to pass more arguments than specified in the help, because in the code it looks like that the other arguments are passed to the mentioned workflow, so it wouldn't launch chrome, but the args parser wouldn't let me do it.

@schultek
Copy link
Owner

schultek commented Mar 7, 2023

Fyi the new cli uses the DevWorkflow directly.

@schultek schultek closed this as completed Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants