diff options
author | Joey Hess <joey@kitenet.net> | 2012-07-27 15:40:52 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-07-27 15:40:52 -0400 |
commit | adae40a292cf3192659f0edef486756431cf97da (patch) | |
tree | 2080988053fe427afe33b5b9eade5e9d770c395f /Command/WebApp.hs | |
parent | 02ec8ea01254637facb30f77b7cb74be3b735c0d (diff) |
now the webapp has the same options as the assistant
Diffstat (limited to 'Command/WebApp.hs')
-rw-r--r-- | Command/WebApp.hs | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/Command/WebApp.hs b/Command/WebApp.hs index 1635ac044..ee1274f97 100644 --- a/Command/WebApp.hs +++ b/Command/WebApp.hs @@ -12,37 +12,33 @@ import Command import Assistant import Utility.WebApp import Utility.Daemon (checkDaemon) -import Option +import qualified Command.Watch def :: [Command] -def = [withOptions [restartOption] $ +def = [withOptions [Command.Watch.foregroundOption, Command.Watch.stopOption] $ command "webapp" paramNothing seek "launch webapp"] -restartOption :: Option -restartOption = Option.flag [] "restart" "restart the assistant daemon" - seek :: [CommandSeek] -seek = [withFlag restartOption $ \restart -> withNothing $ start restart] +seek = [withFlag Command.Watch.stopOption $ \stopdaemon -> + withFlag Command.Watch.foregroundOption $ \foreground -> + withNothing $ start foreground stopdaemon] -start :: Bool -> CommandStart -start restart = notBareRepo $ do - f <- liftIO . absPath =<< fromRepo gitAnnexHtmlShim - if restart - then do - stopDaemon - void $ liftIO . nukeFile =<< fromRepo gitAnnexPidFile - startassistant f - else ifM (checkpid <&&> checkshim f) $ - ( liftIO $ go f - , startassistant f - ) +start :: Bool -> Bool -> CommandStart +start foreground stopdaemon = notBareRepo $ do + if stopdaemon + then stopDaemon + else do + f <- liftIO . absPath =<< fromRepo gitAnnexHtmlShim + ifM (checkpid <&&> checkshim f) $ + ( liftIO $ go f + , startDaemon True foreground $ Just $ go f + ) stop where checkpid = do pidfile <- fromRepo gitAnnexPidFile liftIO $ isJust <$> checkDaemon pidfile checkshim f = liftIO $ doesFileExist f - startassistant = startDaemon True False . Just . go go f = unlessM (runBrowser url) $ error $ "failed to start web browser on url " ++ url where |