on second thought, let's use --restart rather than --force
--force could enable other, unwanted behavior
This commit is contained in:
parent
a453be4195
commit
3c117685eb
1 changed files with 13 additions and 9 deletions
|
@ -13,29 +13,33 @@ import Assistant
|
||||||
import Utility.WebApp
|
import Utility.WebApp
|
||||||
import Utility.Daemon (checkDaemon)
|
import Utility.Daemon (checkDaemon)
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
|
import Option
|
||||||
|
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
import System.Posix.Process
|
import System.Posix.Process
|
||||||
|
|
||||||
def :: [Command]
|
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 :: [CommandSeek]
|
||||||
seek = [withNothing start]
|
seek = [withFlag restartOption $ \restart -> withNothing $ start restart]
|
||||||
|
|
||||||
start :: CommandStart
|
start :: Bool -> CommandStart
|
||||||
start = notBareRepo $ do
|
start restart = notBareRepo $ do
|
||||||
ifM (Annex.getState Annex.force)
|
if restart
|
||||||
( do
|
then do
|
||||||
stopDaemon
|
stopDaemon
|
||||||
liftIO . catchMaybeIO . removeFile
|
void $ liftIO . catchMaybeIO . removeFile
|
||||||
=<< fromRepo gitAnnexPidFile
|
=<< fromRepo gitAnnexPidFile
|
||||||
startassistant
|
startassistant
|
||||||
, do
|
else do
|
||||||
r <- checkpid
|
r <- checkpid
|
||||||
when (r == Nothing) $
|
when (r == Nothing) $
|
||||||
startassistant
|
startassistant
|
||||||
)
|
|
||||||
f <- liftIO . absPath =<< fromRepo gitAnnexHtmlShim
|
f <- liftIO . absPath =<< fromRepo gitAnnexHtmlShim
|
||||||
let url = "file://" ++ f
|
let url = "file://" ++ f
|
||||||
ifM (liftIO $ runBrowser url)
|
ifM (liftIO $ runBrowser url)
|
||||||
|
|
Loading…
Reference in a new issue