remove unimplemented windows stubs
This commit is contained in:
parent
556cfeb8f0
commit
b2fae4b78f
2 changed files with 4 additions and 16 deletions
|
@ -21,6 +21,7 @@ import Control.Concurrent.Async
|
||||||
import System.PosixCompat.Types
|
import System.PosixCompat.Types
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef mingw32_HOST_OS
|
||||||
{- Run an action as a daemon, with all output sent to a file descriptor.
|
{- Run an action as a daemon, with all output sent to a file descriptor.
|
||||||
-
|
-
|
||||||
- Can write its pid to a file, to guard against multiple instances
|
- Can write its pid to a file, to guard against multiple instances
|
||||||
|
@ -28,7 +29,6 @@ import System.PosixCompat.Types
|
||||||
-
|
-
|
||||||
- When successful, does not return. -}
|
- When successful, does not return. -}
|
||||||
daemonize :: Fd -> Maybe FilePath -> Bool -> IO () -> IO ()
|
daemonize :: Fd -> Maybe FilePath -> Bool -> IO () -> IO ()
|
||||||
#ifndef mingw32_HOST_OS
|
|
||||||
daemonize logfd pidfile changedirectory a = do
|
daemonize logfd pidfile changedirectory a = do
|
||||||
maybe noop checkalreadyrunning pidfile
|
maybe noop checkalreadyrunning pidfile
|
||||||
_ <- forkProcess child1
|
_ <- forkProcess child1
|
||||||
|
@ -52,8 +52,6 @@ daemonize logfd pidfile changedirectory a = do
|
||||||
wait =<< asyncWithUnmask (\unmask -> unmask a)
|
wait =<< asyncWithUnmask (\unmask -> unmask a)
|
||||||
out
|
out
|
||||||
out = exitImmediately ExitSuccess
|
out = exitImmediately ExitSuccess
|
||||||
#else
|
|
||||||
daemonize = error "daemonize is not implemented on Windows" -- TODO
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{- Locks the pid file, with an exclusive, non-blocking lock.
|
{- Locks the pid file, with an exclusive, non-blocking lock.
|
||||||
|
@ -112,13 +110,11 @@ checkDaemon pidfile = do
|
||||||
checkDaemon pidfile = maybe Nothing readish <$> catchMaybeIO (readFile pidfile)
|
checkDaemon pidfile = maybe Nothing readish <$> catchMaybeIO (readFile pidfile)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef mingw32_HOST_OS
|
||||||
{- Stops the daemon, safely. -}
|
{- Stops the daemon, safely. -}
|
||||||
stopDaemon :: FilePath -> IO ()
|
stopDaemon :: FilePath -> IO ()
|
||||||
#ifndef mingw32_HOST_OS
|
|
||||||
stopDaemon pidfile = go =<< checkDaemon pidfile
|
stopDaemon pidfile = go =<< checkDaemon pidfile
|
||||||
where
|
where
|
||||||
go Nothing = noop
|
go Nothing = noop
|
||||||
go (Just pid) = signalProcess sigTERM pid
|
go (Just pid) = signalProcess sigTERM pid
|
||||||
#else
|
|
||||||
stopDaemon = error "stopDaemon is not implemented on Windows" -- TODO
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,14 +13,12 @@ import Common
|
||||||
|
|
||||||
import System.Posix.Types
|
import System.Posix.Types
|
||||||
|
|
||||||
openLog :: FilePath -> IO Fd
|
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
|
openLog :: FilePath -> IO Fd
|
||||||
openLog logfile = do
|
openLog logfile = do
|
||||||
rotateLog logfile
|
rotateLog logfile
|
||||||
openFd logfile WriteOnly (Just stdFileMode)
|
openFd logfile WriteOnly (Just stdFileMode)
|
||||||
defaultFileFlags { append = True }
|
defaultFileFlags { append = True }
|
||||||
#else
|
|
||||||
openLog = error "openLog TODO"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rotateLog :: FilePath -> IO ()
|
rotateLog :: FilePath -> IO ()
|
||||||
|
@ -49,20 +47,14 @@ listLogs logfile = filterM doesFileExist $ reverse $
|
||||||
maxLogs :: Int
|
maxLogs :: Int
|
||||||
maxLogs = 9
|
maxLogs = 9
|
||||||
|
|
||||||
redirLog :: Fd -> IO ()
|
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
|
redirLog :: Fd -> IO ()
|
||||||
redirLog logfd = do
|
redirLog logfd = do
|
||||||
mapM_ (redir logfd) [stdOutput, stdError]
|
mapM_ (redir logfd) [stdOutput, stdError]
|
||||||
closeFd logfd
|
closeFd logfd
|
||||||
#else
|
|
||||||
redirLog _ = error "redirLog TODO"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
redir :: Fd -> Fd -> IO ()
|
redir :: Fd -> Fd -> IO ()
|
||||||
#ifndef mingw32_HOST_OS
|
|
||||||
redir newh h = do
|
redir newh h = do
|
||||||
closeFd h
|
closeFd h
|
||||||
void $ dupTo newh h
|
void $ dupTo newh h
|
||||||
#else
|
|
||||||
redir _ _ = error "redir TODO"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue