webapp: Now always logs to .git/annex/daemon.log

It used to not log to daemon.log when a repository was first created, and
when starting the webapp. Now both do. Redirecting stdout and stderr to the
log is tricky when starting the webapp, because the web browser may want to
communicate with the user. (Either a console web browser, or web.browser = echo)
This is handled by restoring the original fds when running the browser.
This commit is contained in:
Joey Hess 2013-01-15 13:34:59 -04:00
parent f9ec512c8f
commit d7ca6fb856
6 changed files with 74 additions and 55 deletions

View file

@ -40,16 +40,12 @@ import Control.Concurrent
localhost :: String
localhost = "localhost"
{- Runs a web browser on a given url.
-
- Note: The url *will* be visible to an attacker. -}
runBrowser :: String -> (Maybe [(String, String)]) -> IO Bool
runBrowser url env = boolSystemEnv cmd [Param url] env
where
{- Command to use to run a web browser. -}
browserCommand :: FilePath
#ifdef darwin_HOST_OS
cmd = "open"
browserCommand = "open"
#else
cmd = "xdg-open"
browserCommand = "xdg-open"
#endif
{- Binds to a socket on localhost, and runs a webapp on it.