Crystal launch in production mode

I launch my Crystal Webapp, creating it, and then run the executable. However, it always listens on port 3000.

How do I create / run Crystal Webapps while listening to 80 and 443?

I also use Kemal. Here is an example application.

require "kemal"

get "/" do
  "Hello World!"
end

Kemal.run

Building:

crystal build src/myapp.cr

Duration:

./myapp
+4
source share
1 answer

Just pass the port Kemal.run:

require "kemal"

get "/" do
  "Hello World!"
end

port = ARGV[0]?.try &.to_i?
Kemal.run port

Addition:

crystal build src/myapp.cr

Run:

./myapp # default port 3000
./myapp 80
./myapp 443
+5
source

Source: https://habr.com/ru/post/1693783/


All Articles