@@ -7,8 +7,8 @@ module Ariadne.MainTemplate
77
88import Control.Concurrent (forkIO , myThreadId , throwTo )
99import Control.Concurrent.Async
10- (Async (.. ), AsyncCancelled (.. ), ExceptionInLinkedThread (.. ), race_ ,
11- waitCatch , withAsync )
10+ (Async (.. ), AsyncCancelled (.. ), ExceptionInLinkedThread (.. ), concurrently ,
11+ race_ , waitCatch , withAsync )
1212import Control.Monad.Component (ComponentM , runComponentM )
1313import Control.Natural (($$) )
1414import Data.Version (Version )
@@ -25,7 +25,7 @@ import Ariadne.Config.History (HistoryConfig(..))
2525import Ariadne.Config.Logging (LoggingConfig (.. ))
2626import Ariadne.Config.Wallet (WalletConfig (.. ))
2727import Ariadne.Knit.Backend (Components , KnitFace , createKnitBackend )
28- import Ariadne.Logging (Logging , loggingComponent )
28+ import Ariadne.Logging (Logging , logDebug , loggingComponent )
2929import Ariadne.TaskManager.Backend
3030import Ariadne.Update.Backend
3131import Ariadne.UX.CommandHistory
@@ -89,7 +89,7 @@ defaultMain settings = do
8989
9090initializeEverything
9191 :: forall uiComponents uiFace uiLangFace .
92- (Components (AllComponents uiComponents ))
92+ (Components (AllComponents uiComponents ), HasCallStack )
9393 => MainSettings uiComponents uiFace uiLangFace
9494 -> AriadneConfig
9595 -> ComponentM (IO () )
@@ -169,21 +169,23 @@ initializeEverything MainSettings {..}
169169 initAction :: IO ()
170170 initAction = walletInitAction
171171
172+ postStartupAction :: IO ()
173+ postStartupAction = postInitAction
174+
172175 serviceAction :: IO ()
173176 serviceAction =
174177 raceWithUpdateCheckAction cardanoAction
175178
176179 mainAction :: IO ()
177180 mainAction = do
178181 initAction
179- withAsync postInitAction $ \ postInitActionThread -> do
180- linkUI postInitActionThread $ msPutBackendErrorToUI uiFace
181182 -- Spawn backend actions in async thread, then run ui action in the main thread
182183 -- This is needed because some UI libraries (Qt) insist on livng in the main thread
183- withAsync serviceAction $ \ serviceThread -> do
184+ withAsync (concurrently postStartupAction serviceAction) $ \ serviceThread -> do
184185 -- Make custom link to service thread for UI apps.
185186 -- It is going to call msPutBackendErrorToUI and rethrow exception, if something goes wrong
186187 linkUI serviceThread $ msPutBackendErrorToUI uiFace
188+ logDebug logging " Launching the UI..."
187189 uiAction
188190 return mainAction
189191
0 commit comments