assistant: Logs are rotated to avoid them using too much disk space.

This cannot completely guard against a runaway log event, and only runs
every hour anyway, but it should avoid most problems with very
long-running, active assistants using up too much space.
This commit is contained in:
Joey Hess 2013-03-01 13:30:48 -04:00
parent fed56e24a4
commit 1865b28094
5 changed files with 73 additions and 34 deletions

View file

@ -8,6 +8,7 @@
module Utility.Daemon where
import Common
import Utility.LogFile
import System.Posix
@ -40,16 +41,6 @@ daemonize logfd pidfile changedirectory a = do
out
out = exitImmediately ExitSuccess
redirLog :: Fd -> IO ()
redirLog logfd = do
mapM_ (redir logfd) [stdOutput, stdError]
closeFd logfd
redir :: Fd -> Fd -> IO ()
redir newh h = do
closeFd h
void $ dupTo newh h
{- Locks the pid file, with an exclusive, non-blocking lock.
- Writes the pid to the file, fully atomically.
- Fails if the pid file is already locked by another process. -}