git.iko.soy/distributed-process
on master help sign in
Merge pull request #80 from simonmar/master

Shut down the logger process before exiting.

commit8bc0d4a927df4112682121d86c447292a274ff64 authorEdsko de Vries <edsko@well-typed.com> dateMon 3 Dec 2012, 08:30 (14 years ago) parent8a6a6ca53b2be7
1 file changed+18−1
distributed-process-simplelocalnet/src/Control/Distributed/Process/Backend/SimpleLocalnet.hs+18−1
distributed-process-simplelocalnet/src/Control/Distributed/Process/Backend/SimpleLocalnet.hs+18−1
@@ -127,6 +127,11 @@ import Control.Distributed.Process
127127 , monitorNode
128128 , unmonitor
129129 , NodeMonitorNotification(..)
130+ , finally
131+ , newChan
132+ , receiveChan
133+ , nsend
134+ , SendPort
130135 )
131136import qualified Control.Distributed.Process.Node as Node
132137 ( LocalNode
@@ -349,7 +354,19 @@ startMaster backend proc = do
349354 Node.runProcess node $ do
350355 slaves <- findSlaves backend
351356 redirectLogsHere backend
352− proc slaves
357+ proc slaves `finally` shutdownLogger
358+
359+--
360+-- | shut down the logger process. This ensures that any pending
361+-- messages are flushed before the process exits.
362+--
363+shutdownLogger :: Process ()
364+shutdownLogger = do
365+ (sport,rport) <- newChan
366+ nsend "logger" (sport :: SendPort ())
367+ receiveChan rport
368+ -- TODO: we should monitor the logger process so we don't deadlock if
369+ -- it has already died.
353370
354371--------------------------------------------------------------------------------
355372-- Accessors --