on second thought, let's use --restart rather than --force

--force could enable other, unwanted behavior
This commit is contained in:
Joey Hess 2012-07-26 12:17:28 -04:00
parent a453be4195
commit 3c117685eb

View file

@ -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)