summaryrefslogtreecommitdiff
path: root/Command/WebApp.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-26 12:17:28 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-07-26 12:17:28 -0400
commit3c117685ebaceb1b33ba2058255ef55518a0f850 (patch)
tree903c7bc19fd3d877c98cc2cec9a42bb5e591d0b1 /Command/WebApp.hs
parenta453be4195c36d8214ab44eafbb403ed55bc1d87 (diff)
on second thought, let's use --restart rather than --force
--force could enable other, unwanted behavior
Diffstat (limited to 'Command/WebApp.hs')
-rw-r--r--Command/WebApp.hs22
1 files changed, 13 insertions, 9 deletions
diff --git a/Command/WebApp.hs b/Command/WebApp.hs
index e94338a2f..3730e1419 100644
--- a/Command/WebApp.hs
+++ b/Command/WebApp.hs
@@ -13,29 +13,33 @@ import Assistant
import Utility.WebApp
import Utility.Daemon (checkDaemon)
import qualified Annex
+import Option
import Control.Concurrent
import System.Posix.Process
def :: [Command]
-def = [command "webapp" paramNothing seek "launch webapp"]
+def = [withOptions [restartOption] $
+ command "webapp" paramNothing seek "launch webapp"]
+
+restartOption :: Option
+restartOption = Option.flag [] "restart" "restart the assistant daemon"
seek :: [CommandSeek]
-seek = [withNothing start]
+seek = [withFlag restartOption $ \restart -> withNothing $ start restart]
-start :: CommandStart
-start = notBareRepo $ do
- ifM (Annex.getState Annex.force)
- ( do
+start :: Bool -> CommandStart
+start restart = notBareRepo $ do
+ if restart
+ then do
stopDaemon
- liftIO . catchMaybeIO . removeFile
+ void $ liftIO . catchMaybeIO . removeFile
=<< fromRepo gitAnnexPidFile
startassistant
- , do
+ else do
r <- checkpid
when (r == Nothing) $
startassistant
- )
f <- liftIO . absPath =<< fromRepo gitAnnexHtmlShim
let url = "file://" ++ f
ifM (liftIO $ runBrowser url)