Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/Chainweb/Chainweb.hs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ import Chainweb.Chainweb.MempoolSyncClient
import Chainweb.Chainweb.MinerResources
import Chainweb.Chainweb.PeerResources
import Chainweb.Chainweb.PruneChainDatabase
import Chainweb.Counter
import qualified Chainweb.Counter as Counter
import Chainweb.Cut
import Chainweb.CutDB
import Chainweb.HostAddress
Expand Down Expand Up @@ -387,12 +387,12 @@ withChainwebInternal conf logger peer serviceSock rocksDb pactDbDir backupDir re
logg Info "finished pruning databases"
logFunctionJson logger Info InitializingChainResources

txFailuresCounter <- newCounter @"txFailures"
txFailuresCounter <- Counter.newCounter @"txFailures"
let monitorTxFailuresCounter =
runForever (logFunctionText logger) "monitor txFailuresCounter" $ do
approximateThreadDelay 60_000_000 {- 1 minute -}
logFunctionCounter logger Info . (:[]) =<<
roll txFailuresCounter
Counter.logFunctionCounter logger Info . (:[]) =<<
Counter.roll txFailuresCounter
logg Debug "start initializing chain resources"
logFunctionText logger Info $ "opening pact db in directory " <> sshow pactDbDir
withAsync monitorTxFailuresCounter $ \_ ->
Expand Down Expand Up @@ -797,7 +797,7 @@ runChainweb cw nowServing = do
| Just InsecureConnectionDenied <- fromException e =
return ()
| Just ClientClosedConnectionPrematurely <- fromException e =
inc clientClosedConnectionsCounter
Counter.inc clientClosedConnectionsCounter
-- this isn't really an error, this is a graceful close.
-- see https://github.com/kazu-yamamoto/http2/issues/102
| Just HTTP2.ConnectionIsClosed <- fromException e =
Expand All @@ -808,22 +808,22 @@ runChainweb cw nowServing = do

-- P2P Server

serverSettings :: Counter "clientClosedConnections" -> Settings
serverSettings :: Counter.Counter "clientClosedConnections" -> Settings
serverSettings clientClosedConnectionsCounter =
peerServerSettings (_peerResPeer $ _chainwebPeer cw)
& setOnException (logWarpException "P2P API" clientClosedConnectionsCounter)
& setBeforeMainLoop (nowServing (nowServingP2PAPI .~ True))

monitorConnectionsClosedByClient :: Counter "clientClosedConnections" -> IO ()
monitorConnectionsClosedByClient :: Counter.Counter "clientClosedConnections" -> IO ()
monitorConnectionsClosedByClient clientClosedConnectionsCounter =
runForever logg "ConnectionClosedByClient.counter" $ do
approximateThreadDelay 60_000_000 {- 1 minute -}
logFunctionCounter (_chainwebLogger cw) Info . (:[]) =<<
roll clientClosedConnectionsCounter
Counter.logFunctionCounter (_chainwebLogger cw) Info . (:[]) =<<
Counter.roll clientClosedConnectionsCounter

serve :: Middleware -> IO ()
serve mw = do
clientClosedConnectionsCounter <- newCounter
clientClosedConnectionsCounter <- Counter.newCounter
concurrently_
(serveChainwebSocketTls
(serverSettings clientClosedConnectionsCounter)
Expand All @@ -844,7 +844,7 @@ runChainweb cw nowServing = do
-- serve without tls
servePlain :: Middleware -> IO ()
servePlain mw = do
clientClosedConnectionsCounter <- newCounter
clientClosedConnectionsCounter <- Counter.newCounter
concurrently_
(serveChainwebSocket
(serverSettings clientClosedConnectionsCounter)
Expand Down Expand Up @@ -887,7 +887,7 @@ runChainweb cw nowServing = do
-- Service API Server

serviceApiServerSettings
:: Counter "clientClosedConnections"
:: Counter.Counter "clientClosedConnections"
-> Port -> HostPreference -> Settings
serviceApiServerSettings clientClosedConnectionsCounter port interface = defaultSettings
& setPort (int port)
Expand All @@ -903,7 +903,7 @@ runChainweb cw nowServing = do

serveServiceApi :: Middleware -> IO ()
serveServiceApi mw = do
clientClosedConnectionsCounter <- newCounter
clientClosedConnectionsCounter <- Counter.newCounter
serveServiceApiSocket
(serviceApiServerSettings clientClosedConnectionsCounter (fst $ _chainwebServiceSocket cw) serviceApiHost)
(snd $ _chainwebServiceSocket cw)
Expand Down
Loading