diff --git a/src/ATrade/Driver/Junction.hs b/src/ATrade/Driver/Junction.hs index f1eb142..127b57d 100644 --- a/src/ATrade/Driver/Junction.hs +++ b/src/ATrade/Driver/Junction.hs @@ -147,6 +147,7 @@ junctionMain descriptors = do peRobots = robotsMap, peRemoteControlSocket = rcSocket, peLogAction = junctionLogAction, + peIoLogAction = globalLogger, peProgramConfiguration = cfg, peBarsMap = barsMap, peTickerInfoMap = tickerInfoMap, @@ -154,16 +155,16 @@ junctionMain descriptors = do peDescriptors = descriptors } withJunction env $ do - startRobots (hoistLogAction liftIO globalLogger) cfg + startRobots cfg forever $ do notifications <- liftIO $ getNotifications broService forM_ notifications (liftIO . handleBrokerNotification robotsMap ordersMap handledNotifications globalLogger) saveRobots handleRemoteControl 1000000 where - startRobots :: LogAction IO Message -> ProgramConfiguration -> JunctionM () - startRobots gLogger cfg = forM_ (instances cfg) $ \inst -> do - startRobot gLogger inst + startRobots :: ProgramConfiguration -> JunctionM () + startRobots cfg = forM_ (instances cfg) $ \inst -> do + startRobot inst withJunction :: JunctionEnv -> JunctionM () -> IO () withJunction env = (`runReaderT` env) . unJunctionM diff --git a/src/ATrade/Driver/Junction/JunctionMonad.hs b/src/ATrade/Driver/Junction/JunctionMonad.hs index 173c142..22d0df9 100644 --- a/src/ATrade/Driver/Junction/JunctionMonad.hs +++ b/src/ATrade/Driver/Junction/JunctionMonad.hs @@ -94,6 +94,7 @@ data JunctionEnv = peRobots :: IORef (M.Map T.Text RobotDriverHandle), peRemoteControlSocket :: Socket Rep, peLogAction :: LogAction JunctionM Message, + peIoLogAction :: LogAction IO Message, peProgramConfiguration :: ProgramConfiguration, peBarsMap :: IORef Bars, peTickerInfoMap :: IORef TickerInfoMap, @@ -151,8 +152,9 @@ instance QuoteStream JunctionM where qt <- asks peQuoteThread QT.removeSubscription qt subId -startRobot :: LogAction IO Message -> StrategyInstanceDescriptor -> JunctionM () -startRobot ioLogger inst = do +startRobot :: StrategyInstanceDescriptor -> JunctionM () +startRobot inst = do + ioLogger <- asks peIoLogAction descriptors <- asks peDescriptors cfg <- asks peProgramConfiguration barsMap <- asks peBarsMap