mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-09-20 23:18:00 +03:00
king: address joe on fds/seppuku
This commit is contained in:
parent
72f0201de3
commit
1a39dac437
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user