fresh icon indicating copy to clipboard operation
fresh copied to clipboard

deno serve --parallel

Open kesavkolla opened this issue 1 year ago • 3 comments

Is it possible to use the deno serve with fresh? When I try to run deno serve --parallel dev.ts it spun 8 different ports. This is not ideal behavior. deno serve automatically handles the multi worker listening on single port. Is there any way to leverage that for fresh?

kesavkolla avatar Sep 05 '24 01:09 kesavkolla

The deno serve command is currently not supported with Fresh, but the plan is to move over to that. Currently, Fresh spawns its own server via the Deno.serve JS API.

marvinhagemeister avatar Sep 05 '24 07:09 marvinhagemeister

The deno serve command is currently not supported with Fresh, but the plan is to move over to that. Currently, Fresh spawns its own server via the Deno.serve JS API.

A workaround (in fresh 2) is to use the handler right?

fro-profesional avatar Sep 17 '24 04:09 fro-profesional

yup, that can be used with deno serve

marvinhagemeister avatar Sep 17 '24 07:09 marvinhagemeister

here's a simple serve.ts I created to make this work ksnip_20241109-055034

It's clear that some of fresh config, like FreshConfig.server, can't be applied here @marvinhagemeister can I do this? Any suggestions?

shuaixr avatar Nov 09 '24 11:11 shuaixr

@marvinhagemeister @fro-profesional : Do you mind sharing how to use --parallel in Fresh 2.x?

devfacet avatar Jul 21 '25 16:07 devfacet

Sure:

const app = new App()
  .get("/", () => new Response("hello"));

export default {
  fetch: app.handler()
};

marvinhagemeister avatar Jul 21 '25 16:07 marvinhagemeister

@marvinhagemeister: Thank you for your quick reply. I assume fetch does the trick, right? Is there a discussion/PR you could point out? I'm just curious the implementation details. That's all. Thanks again.

devfacet avatar Jul 21 '25 17:07 devfacet

The relevant docs for deno serve are here https://docs.deno.com/runtime/reference/cli/serve/ . It's something built into Deno and available for everyone, not just Fresh.

marvinhagemeister avatar Jul 21 '25 18:07 marvinhagemeister