diff --git a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs index e7518731b..9dbb71822 100644 --- a/pkg/hs/urbit-king/lib/Urbit/King/Main.hs +++ b/pkg/hs/urbit-king/lib/Urbit/King/Main.hs @@ -704,9 +704,13 @@ main = do Sys.installHandler sig (Sys.Catch onKillSig) Nothing setRLimits = do - nofiles <- Sys.getResourceLimit Sys.ResourceOpenFiles + openFiles <- Sys.getResourceLimit Sys.ResourceOpenFiles + let soft = case Sys.hardLimit openFiles of + Sys.ResourceLimit lim -> Sys.ResourceLimit lim + Sys.ResourceLimitInfinity -> Sys.ResourceLimit 10240 -- macOS + Sys.ResourceLimitUnknown -> Sys.ResourceLimit 10240 Sys.setResourceLimit Sys.ResourceOpenFiles - nofiles { Sys.softLimit = Sys.ResourceLimit 10240 } + openFiles { Sys.softLimit = soft } verboseLogging :: CLI.Cmd -> Bool verboseLogging = \case diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs index 7130e79b7..b426009f1 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre.hs @@ -363,7 +363,7 @@ eyre env who plan isFake stderr sub = (initialEvents, runHttpServer) logInfo "Restarting http server" let onFatal = runRIO env $ do -- XX instead maybe restart following logic under HSESetConfig below - stderr "You've been DDoSed. Please restart your ship." + stderr "A web server problem has occurred. Please restart your ship." view killKingActionL >>= atomically let startAct = startServ who isFake conf plan stderr onFatal sub res <- fromEither =<< restartService var startAct kill diff --git a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs index 59186a156..2bd8a2264 100644 --- a/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs +++ b/pkg/hs/urbit-king/lib/Urbit/Vere/Eyre/Serv.hs @@ -264,18 +264,28 @@ startServer typ hos por sok red vLive onFatal = do SHLocalhost -> "127.0.0.1" SHAnyHostOk -> "*" - let handler r e + let handler r e = do + when (isFatal e) $ do + runRIO envir $ logError $ display $ msg r e + onFatal + when (W.defaultShouldDisplayException e) $ do + runRIO envir $ logWarn $ display $ msg r e + + isFatal e | Just (IOError {ioe_type = ResourceExhausted}) <- fromException e - = runRIO envir $ do - logError (displayShow e) - io onFatal - | otherwise = W.defaultOnException r e + = True + | otherwise = False + + msg r e = case r of + Just r -> "eyre: failed request from " <> (tshow $ W.remoteHost r) + <> " for " <> (tshow $ W.rawPathInfo r) <> ": " <> tshow e + Nothing -> "eyre: server exception: " <> tshow e let opts = W.defaultSettings & W.setHost host & W.setPort (fromIntegral por) - & W.setTimeout (5 * 60) + & W.setTimeout 30 & W.setOnException handler -- TODO build Eyre.Site.app in pier, thread through here