webapp: Add UI to stop assistant.
Would like to also have restart UI, but that's rather harder to do, seems it'd need to start another copy of the webapp, and redirect the browser to its new url, but running two assistants in the same repo at the same time isn't good.
This commit is contained in:
parent
d5f18291c5
commit
de2e287133
10 changed files with 61 additions and 10 deletions
28
Assistant/WebApp/Control.hs
Normal file
28
Assistant/WebApp/Control.hs
Normal file
|
@ -0,0 +1,28 @@
|
|||
{- git-annex assistant webapp control
|
||||
-
|
||||
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE CPP, TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}
|
||||
|
||||
module Assistant.WebApp.Control where
|
||||
|
||||
import Assistant.WebApp.Common
|
||||
|
||||
import Control.Concurrent
|
||||
import System.Posix (getProcessID, signalProcess, sigTERM)
|
||||
|
||||
getShutdownR :: Handler RepHtml
|
||||
getShutdownR = page "Shutdown" Nothing $
|
||||
$(widgetFile "control/shutdown")
|
||||
|
||||
getShutdownConfirmedR :: Handler RepHtml
|
||||
getShutdownConfirmedR = page "Shutdown" Nothing $ do
|
||||
{- Wait 2 seconds before shutting down, to give the web page time
|
||||
- to display. -}
|
||||
void $ liftIO $ forkIO $ do
|
||||
threadDelay 2000000
|
||||
signalProcess sigTERM =<< getProcessID
|
||||
$(widgetFile "control/shutdownconfirmed")
|
Loading…
Add table
Add a link
Reference in a new issue