Open kennedymwavu opened 3 days ago
You're correct that better checks should be passed but we should also take that opportunity to rethink this a bit, namely in light of your discovery that it can be deployed on shiny server.
Perhaps the port
argument could default to a convenience function that resolved the port somewhat intelligently, e.g.: port = get_port()
which:
What do you think?
that'd be great!
AMBIORIX_PORT
would be a good name for the env var, no?
explanation
should we do checks on the provided port? most of the times during deployment, the port number is fetched from an env file. however, if the env var is not set (mostly just forgetting),
Sys.getenv()
returns an empty string. if passed to ambiorix, it is coerced intoNA
byas.integer()
. this has bitten me a few times.reprex
when you run the above, you get this on the console:
question
should we validate that the given port is indeed an integer and not
NA_integer_
? throw error maybe?hint
this should suffice:
this change can be made just before passing the port to
httpuv::startServer()
, here