elixir-plug / plug

Compose web applications with functions
https://hex.pm/packages/plug
Other
2.84k stars 582 forks source link

error :plug_cowboy #1142

Closed alex1543 closed 1 year ago

alex1543 commented 1 year ago

Dear Developer, help me understand.

:plug cowboy does not work under Windows. The example starts without errors, but the page does not open http://localhost:4000/ There is no plug in the process list "netstat -a -b". The bug manifests itself regardless of the port: 4000, 8181, 3000, 3001, etc. How can the error be corrected?

  1. Operating system: Windows 11 Home, Version: 22H2, Build: 22621.1485;
  2. Version: Erlang/OTP 25 [erts-13.2] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit:ns] and Elixir 1.14.4 (compiled with Erlang/OTP25)
  3. I run the example with the command: C:\Elixir\bin\elixir --no-halt hello_world.exs Grateful for any hint. Thank you for your attention to me. Example runs according to https://github.com/elixir-plug/plug
josevalim commented 1 year ago

Can you try adding a Process.sleep(:infinity) as the last line of the file and see if that fixes it?

alex1543 commented 1 year ago

Everything worked, thanks.

yumaikas commented 1 year ago

Might I ask why this works?

josevalim commented 1 year ago

Starting a supervision tree process does not block the main execution. So when the file finished, the whole program terminated.