now the webapp has the same options as the assistant
This commit is contained in:
parent
02ec8ea012
commit
adae40a292
1 changed files with 15 additions and 19 deletions
|
@ -12,29 +12,26 @@ import Command
|
||||||
import Assistant
|
import Assistant
|
||||||
import Utility.WebApp
|
import Utility.WebApp
|
||||||
import Utility.Daemon (checkDaemon)
|
import Utility.Daemon (checkDaemon)
|
||||||
import Option
|
import qualified Command.Watch
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [withOptions [restartOption] $
|
def = [withOptions [Command.Watch.foregroundOption, Command.Watch.stopOption] $
|
||||||
command "webapp" paramNothing seek "launch webapp"]
|
command "webapp" paramNothing seek "launch webapp"]
|
||||||
|
|
||||||
restartOption :: Option
|
|
||||||
restartOption = Option.flag [] "restart" "restart the assistant daemon"
|
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
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 :: Bool -> Bool -> CommandStart
|
||||||
start restart = notBareRepo $ do
|
start foreground stopdaemon = notBareRepo $ do
|
||||||
|
if stopdaemon
|
||||||
|
then stopDaemon
|
||||||
|
else do
|
||||||
f <- liftIO . absPath =<< fromRepo gitAnnexHtmlShim
|
f <- liftIO . absPath =<< fromRepo gitAnnexHtmlShim
|
||||||
if restart
|
ifM (checkpid <&&> checkshim f) $
|
||||||
then do
|
|
||||||
stopDaemon
|
|
||||||
void $ liftIO . nukeFile =<< fromRepo gitAnnexPidFile
|
|
||||||
startassistant f
|
|
||||||
else ifM (checkpid <&&> checkshim f) $
|
|
||||||
( liftIO $ go f
|
( liftIO $ go f
|
||||||
, startassistant f
|
, startDaemon True foreground $ Just $ go f
|
||||||
)
|
)
|
||||||
stop
|
stop
|
||||||
where
|
where
|
||||||
|
@ -42,7 +39,6 @@ start restart = notBareRepo $ do
|
||||||
pidfile <- fromRepo gitAnnexPidFile
|
pidfile <- fromRepo gitAnnexPidFile
|
||||||
liftIO $ isJust <$> checkDaemon pidfile
|
liftIO $ isJust <$> checkDaemon pidfile
|
||||||
checkshim f = liftIO $ doesFileExist f
|
checkshim f = liftIO $ doesFileExist f
|
||||||
startassistant = startDaemon True False . Just . go
|
|
||||||
go f = unlessM (runBrowser url) $
|
go f = unlessM (runBrowser url) $
|
||||||
error $ "failed to start web browser on url " ++ url
|
error $ "failed to start web browser on url " ++ url
|
||||||
where
|
where
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue