service config, integrate service launch into DHT launch
TODO: hold a reference from DHT to service
This commit is contained in:
parent
da47f8062f
commit
98ca0ff13e
6 changed files with 56 additions and 32 deletions
20
app/Main.hs
20
app/Main.hs
|
@ -10,15 +10,17 @@ import Data.IP (IPv6, toHostAddress6)
|
|||
import System.Environment
|
||||
|
||||
import Hash2Pub.FediChord
|
||||
import Hash2Pub.FediChordTypes
|
||||
import Hash2Pub.PostService (PostService (..))
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
-- ToDo: parse and pass config
|
||||
-- probably use `tomland` for that
|
||||
conf <- readConfig
|
||||
(fConf, sConf) <- readConfig
|
||||
-- TODO: first initialise 'RealNode', then the vservers
|
||||
-- ToDo: load persisted caches, bootstrapping nodes …
|
||||
(serverSock, thisNode) <- fediChordInit conf
|
||||
(serverSock, thisNode) <- fediChordInit fConf (runService sConf :: DHT d => d -> IO (PostService d))
|
||||
-- currently no masking is necessary, as there is nothing to clean up
|
||||
nodeCacheWriterThread <- forkIO $ nodeCacheWriter thisNode
|
||||
-- try joining the DHT using one of the provided bootstrapping nodes
|
||||
|
@ -41,10 +43,11 @@ main = do
|
|||
pure ()
|
||||
|
||||
|
||||
readConfig :: IO FediChordConf
|
||||
readConfig :: IO (FediChordConf, ServiceConf)
|
||||
readConfig = do
|
||||
confDomainString : ipString : portString : bootstrapHost : bootstrapPortString : _ <- getArgs
|
||||
pure $ FediChordConf {
|
||||
confDomainString : ipString : portString : bootstrapHost : bootstrapPortString : servicePortString : speedup : _ <- getArgs
|
||||
let
|
||||
fConf = FediChordConf {
|
||||
confDomain = confDomainString
|
||||
, confIP = toHostAddress6 . read $ ipString
|
||||
, confDhtPort = read portString
|
||||
|
@ -53,3 +56,10 @@ readConfig = do
|
|||
, confBootstrapSamplingInterval = 180
|
||||
, confMaxLookupCacheAge = 300
|
||||
}
|
||||
sConf = ServiceConf {
|
||||
confSubscriptionExpiryTime = 2*3600 `div` read speedup
|
||||
, confServicePort = read servicePortString
|
||||
, confServiceHost = confDomainString
|
||||
}
|
||||
pure (fConf, sConf)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue