I am trying to have a simple application combining startMetricsHttpServer() from nim-metrics and have a separate httpServer for my application. At this stage I am trying to just create an API REST endpoint.
I guess it would be unwise to use jester/httpbeast,asyncdispatch and nim-metrics together so I should just stick to chronos and presto. I tried to look into how nimbus-eth1 and nwaku do it but it's a bit complicated codebase for me to understand.
A good starting point is this example: https://github.com/status-im/nim-presto/blob/master/examples/server.nim
On top of that, you have this test that shows how to start metrics: https://github.com/status-im/nim-metrics/blob/master/tests/chronos_server_tests.nim#L22
Each of those can be put in its own async function, then you simply run both at the same time:
proc startMetrics() {.async.} = ...
proc startPresto() {.async.} = ...
waitFor(allFutures(startMetrics(), startPresto()))
Thank you. I've managed to create a working example. Just a question since this is startMetricsHttpServer deprecated but I still have to mimic the createThread stuff?
If I do this:
proc startMetrics() {.async.} = ...
proc startPresto() {.async.} = ...
waitFor(allFutures(startMetrics(), startPresto()))
They still start in the same thread.