mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 18:31:52 +00:00
21 lines
665 B
Haskell
21 lines
665 B
Haskell
module Daemon.RefreshProcDev where
|
|
|
|
import Startlude
|
|
|
|
import Data.IORef
|
|
|
|
import Foundation
|
|
import Lib.Error
|
|
import Lib.External.Metrics.ProcDev
|
|
|
|
refreshProcDev :: AgentCtx -> IO ()
|
|
refreshProcDev agentCtx = do
|
|
let procDevCache = appProcDevMomentCache agentCtx
|
|
(oldTime, oldMoment, _) <- liftIO . readIORef . appProcDevMomentCache $ agentCtx
|
|
|
|
eProcDev <- runS9ErrT $ getProcDevMetrics (oldTime, oldMoment)
|
|
case eProcDev of
|
|
Left e -> putStrLn @Text . show $ e
|
|
Right (newTime, newMoment, newMetrics) -> liftIO $ writeIORef procDevCache (newTime, newMoment, newMetrics)
|
|
|