Bind periodic actions to the main loop
Fixes the issue @anoe was having with the scheduled action to refresh the ngrams context table view.
I have done a bit of refactoring and moved everything around the main server loop, where we have an "allocator" function that schedules all the periodic actions and now the stopGargantext
function will also kill all of the threads when we stop the server. Hopefully this is a pattern we can follow also for other async actions, whenever we need them.
I have tested this locally (with some debug putStrLn
) and it seems to be doing the trick.
Two observations:
-
We should probably get into the habit of using the
LoggerSet
we have as part of theEnv
and use that to emit logs, rather than just naively usingputStrLn
. But for the sake of this MR, I have simply followed the existing pattern; -
The DB functions like
mkCmd
orexecPGSQuery
seems to be over monomorphic -- they seems to make use only of a DB connection but they impose a constraint over aCmd
, which in turn requires "heavier" things likeHasMain
orHasNPLServer
which are perhaps not necessary. Again, fixing this is out of the scope of this MR.
@anoe I'm happy to open issues for 1.
and 2.
.