replace horrible old daemon restart code with new method

This commit is contained in:
Joey Hess 2013-11-23 15:50:17 -04:00
parent cf1f7eb185
commit b1a89c448a
7 changed files with 107 additions and 93 deletions

View file

@ -13,7 +13,7 @@ import Assistant.WebApp.Common
import Assistant.WebApp.Gpg
import Assistant.WebApp.MakeRemote
import Assistant.Sync
import Assistant.Upgrade
import Assistant.Restart
import Init
import qualified Git
import qualified Git.Construct

View file

@ -10,11 +10,10 @@
module Assistant.WebApp.Configurators.Upgrade where
import Assistant.WebApp.Common
import qualified Annex
import Types.Distribution
import Assistant.Upgrade
import Assistant.Restart
import Utility.HumanTime
import Git
import Config
import Data.Time.Clock
@ -31,8 +30,7 @@ getConfigStartUpgradeR d = page "Upgrade git-annex" (Just Configuration) $ do
getConfigFinishUpgradeR :: Handler Html
getConfigFinishUpgradeR = do
liftAssistant prepUpgrade
url <- liftIO . newAssistantUrl
=<< liftAnnex (repoLocation <$> Annex.gitRepo)
url <- liftAssistant runRestart
liftAssistant $ postUpgrade url
redirect url

View file

@ -10,11 +10,11 @@
module Assistant.WebApp.Control where
import Assistant.WebApp.Common
import Config.Files
import Utility.LogFile
import Assistant.DaemonStatus
import Assistant.Alert
import Assistant.TransferSlots
import Assistant.Restart
import Control.Concurrent
import System.Posix (getProcessID, signalProcess, sigTERM)
@ -44,18 +44,12 @@ getShutdownConfirmedR = do
signalProcess sigTERM =<< getProcessID
$(widgetFile "control/shutdownconfirmed")
{- Quite a hack, and doesn't redirect the browser window. -}
getRestartR :: Handler Html
getRestartR = page "Restarting" Nothing $ do
void $ liftIO $ forkIO $ do
threadDelay 2000000
program <- readProgramFile
unlessM (boolSystem "sh" [Param "-c", Param $ restartcommand program]) $
error "restart failed"
$(widgetFile "control/restarting")
where
restartcommand program = program ++ " assistant --stop; exec " ++
program ++ " webapp"
getRestartR = do
liftAssistant prepRestart
url <- liftAssistant runRestart
liftAssistant $ postRestart url
redirect url
getRestartThreadR :: ThreadName -> Handler ()
getRestartThreadR name = do

View file

@ -14,7 +14,7 @@ import Assistant.WebApp.Types
import Assistant.WebApp.Page
import Config.Files
import Utility.Yesod
import Assistant.Upgrade
import Assistant.Restart
getRepositorySwitcherR :: Handler Html
getRepositorySwitcherR = page "Switch repository" Nothing $ do