A peer-to-peer stack for code collaboration
daemon: Non-zero exit code on failure
Thomas Scholtes2688f9c1a0ac
diff --git a/exe/Daemon.hs b/exe/Daemon.hsindex 479caee..1cc1f48 100644--- a/exe/Daemon.hs+++ b/exe/Daemon.hs@@ -69,7 +69,8 @@ opts = Opts<> showDefault)-main :: IO ()+-- We use 'Void' to enforce the use of 'exitFailure'+main :: IO Voidmain = dohSetBuffering stdout LineBufferingOpts{..} <- execParser allOpts@@ -80,7 +81,9 @@ main = dofollows <- readFollowFileIO followFileLock followFileinitRes <- runDaemon env (init follows)case initRes of- Left err -> logErr "Init failed" [] >> logDaemonError err+ Left err -> do+ logDaemonError err+ exitFailureRight _ -> dopolling <- async $ initPolling envlet app = serve Api.daemonApi (server env)@@ -88,10 +91,16 @@ main = doserv <- async $ run port appexc <- waitEitherCatchCancel polling servcase exc of- Left (Left err) -> logErr "Polling failed with an exception" [("error", toS (displayException err))]+ Left (Left err) -> do+ logErr "Polling failed with an exception" [("error", toS (displayException err))]+ exitFailureLeft (Right void') -> absurd void'- Right (Left err) -> logErr "Server failed with an exception" [("error", toS (displayException err))]- Right (Right ()) -> logErr "Server stopped (this should not happen)" []+ Right (Left err) -> do+ logErr "Server failed with an exception" [("error", toS (displayException err))]+ exitFailure+ Right (Right ()) -> do+ logErr "Server stopped (this should not happen)" []+ exitFailurewhereallOpts = info (opts <**> helper)( fullDesc