Setting the koyo port

I have a couple of forms in my config.rkt that I believe set the IP and port of the racket web server:

(define-option http-host #:default "127.0.0.1")
(define-option http-port #:default (or (getenv "PORT") "8000")
  (string->number http-port))

(define-option url-scheme #:default "http"
  (begin0 url-scheme
    (current-application-url-scheme url-scheme)))

(define-option url-host #:default "127.0.0.1"
  (begin0 url-host
    (current-application-url-host url-host)))

(define-option url-port #:default (or (getenv "PORT") "8000")
  (begin0 url-port
    (current-application-url-port (string->number url-port))))

Both http-port and url-port are driven from the <APP_NAME>_PORT env var. Which I haven't set in my .env file.

However when I do a raco chief start I get the following:

22:39:00 web.1    | [2022-06-29 22:39:00.057] [    8894] [  debug] system: starting component server
22:39:00 web.1    | [2022-06-29 22:39:00.058] [    8894] [   info] server: listening on 127.0.0.1:5100
22:39:00 web.1    | [2022-06-29 22:39:00.062] [    8880] [   info] runner: application process started with pid 8894

And sure enough, I can get a login from http://127.0.0.1:5100 but the default is 8000? What am I missing about koyo port configuration?

Chief tries to be helpful by assigning every service in your Procfile a unique port number. It does this by inserting a PORT environment variable into the environment of every spawned process. I see this isn't mentioned in the documentation for chief so I'll have to fix that.

You can ignore this behavior by changing

(define-option http-port #:default (or (getenv "PORT") "8000")
  (string->number http-port))

to

(define-option http-port #:default "8000"
  (string->number http-port))

Ditto for the url-port.

Alternatively, if you add an APP_NAME_PORT entry to your .env file, that'll take precedence.

1 Like

Thanks. While I'm thinking about it can I ask what the difference between url-port and http-port is?

The http-{host,port} options determine what host and port the server listens on and the url-{scheme,host,port} influence the output of make-application-url.

1 Like

cool, so they'd diverge if you were say behind a reverse proxy. In which case the url-{scheme, host, port} would then point to the proxy. Got it, thanks :+1: