add the ability to configure port
This commit is contained in:
parent
eaf58ec580
commit
71a8d771ca
2 changed files with 20 additions and 8 deletions
26
src/app.ml
26
src/app.ml
|
|
@ -37,11 +37,23 @@ let open_registration =
|
||||||
| Error e -> failwith e
|
| Error e -> failwith e
|
||||||
| Ok "true" -> true
|
| Ok "true" -> true
|
||||||
| Ok "false" -> false
|
| Ok "false" -> false
|
||||||
| Ok unknown ->
|
| Ok _unknown ->
|
||||||
failwith
|
failwith "invalid `open_registration` value in configuration file" )
|
||||||
@@ Format.sprintf
|
|
||||||
"invalid value for `open_registration` in configuration file, \
|
|
||||||
expected `true` or `false` but got `%s`"
|
|
||||||
unknown )
|
|
||||||
|
|
||||||
let () = Dream.log "open_registration: %s" (Bool.to_string open_registration)
|
let () = Dream.log "open_registration: %b" open_registration
|
||||||
|
|
||||||
|
let port =
|
||||||
|
match Scfg.Query.get_dir "port" config with
|
||||||
|
| None -> 8080
|
||||||
|
| Some open_registration -> (
|
||||||
|
match Scfg.Query.get_param 0 open_registration with
|
||||||
|
| Error e -> failwith e
|
||||||
|
| Ok n -> (
|
||||||
|
try
|
||||||
|
let n = int_of_string n in
|
||||||
|
if n < 0 then raise (Invalid_argument "negative port number");
|
||||||
|
n
|
||||||
|
with Invalid_argument _msg ->
|
||||||
|
failwith "invalid `port` value in configuration file" ) )
|
||||||
|
|
||||||
|
let () = Dream.log "port: %d" port
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ let routes =
|
||||||
[ get_ "/:thread_id" thread_get; post "/:thread_id" reply_post ]
|
[ get_ "/:thread_id" thread_get; post "/:thread_id" reply_post ]
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
Dream.run ~port:3696 @@ Dream.logger @@ Dream.cookie_sessions
|
Dream.run ~port:App.port @@ Dream.logger @@ Dream.cookie_sessions
|
||||||
(* this should replace memory/cookie sessions but it doesn't work :-(
|
(* this should replace memory/cookie sessions but it doesn't work :-(
|
||||||
@@ Dream.sql_pool Db.db_uri
|
@@ Dream.sql_pool Db.db_uri
|
||||||
@@ Dream.sql_sessions
|
@@ Dream.sql_sessions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue