summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-05-09 12:02:31 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-05-09 12:02:31 -0400
commit86926f1b587542fbabdfae5c7a4f5faa2888b1bc (patch)
treebfbd757c23f341f5ffe01ea8eaa793ddd86f70ba
parent5a3a7f5d65dd1be41375b147a7ed51dbc4e2bf1d (diff)
run checkCanWatch before redirecting errors to log
This was handled ok in daemon mode, but not in foreground mode.
-rw-r--r--Assistant.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/Assistant.hs b/Assistant.hs
index e24614517..039837586 100644
--- a/Assistant.hs
+++ b/Assistant.hs
@@ -177,15 +177,17 @@ startDaemon assistant foreground listenhost startbrowser = do
logfd <- liftIO $ openLog logfile
if foreground
then do
- liftIO $ debugM desc $ "logging to " ++ logfile
- liftIO $ Utility.Daemon.lockPidFile pidfile
+ showStart "." desc
origout <- liftIO $ catchMaybeIO $
fdToHandle =<< dup stdOutput
origerr <- liftIO $ catchMaybeIO $
fdToHandle =<< dup stdError
- liftIO $ Utility.LogFile.redirLog logfd
- showStart "." desc
- start id $
+ let undaemonize a = do
+ debugM desc $ "logging to " ++ logfile
+ Utility.Daemon.lockPidFile pidfile
+ Utility.LogFile.redirLog logfd
+ a
+ start undaemonize $
case startbrowser of
Nothing -> Nothing
Just a -> Just $ a origout origerr