restart on upgrade now fully working
This commit is contained in:
parent
0980f3dae6
commit
7cd9f909e4
2 changed files with 14 additions and 8 deletions
4
Annex.hs
4
Annex.hs
|
@ -255,9 +255,9 @@ withCurrentState a = do
|
|||
- Fix up the Repo to be a non-bare repo, and arrange for git commands
|
||||
- run by git-annex to be passed parameters that override this setting. -}
|
||||
fixupDirect :: Git.Repo -> Git.Repo
|
||||
fixupDirect r@(Repo { location = Local { gitdir = d, worktree = Nothing } }) =
|
||||
fixupDirect r@(Repo { location = l@(Local { gitdir = d, worktree = Nothing }) }) =
|
||||
r
|
||||
{ location = Local { gitdir = d </> ".git", worktree = Just d }
|
||||
{ location = l { worktree = Just (parentDir d) }
|
||||
, gitGlobalOpts = gitGlobalOpts r ++
|
||||
[ Param "-c"
|
||||
, Param $ coreBare ++ "=" ++ boolConfig False
|
||||
|
|
|
@ -23,6 +23,7 @@ import Git
|
|||
|
||||
import Data.Time.Clock
|
||||
import Control.Concurrent
|
||||
import System.Posix (getProcessID, signalProcess, sigTERM)
|
||||
|
||||
getConfigStartUpgradeR :: GitAnnexDistribution -> Handler Html
|
||||
getConfigStartUpgradeR d = page "Upgrade git-annex" (Just Configuration) $ do
|
||||
|
@ -38,6 +39,11 @@ getConfigStartUpgradeR d = page "Upgrade git-annex" (Just Configuration) $ do
|
|||
- gitAnnexUrlFile and our gitAnnexPidFile. Pausing the watcher is also
|
||||
- a good idea, to avoid fighting when two assistants are running in the
|
||||
- same repo.
|
||||
-
|
||||
- Note that only the tag that requested this page gets redirected.
|
||||
- If the user has multiple web browser tabs open to the webapp,
|
||||
- the others will show the upgradingAlert, and keep running until
|
||||
- this process is terminated.
|
||||
-}
|
||||
getConfigFinishUpgradeR :: Handler Html
|
||||
getConfigFinishUpgradeR = do
|
||||
|
@ -45,12 +51,12 @@ getConfigFinishUpgradeR = do
|
|||
liftIO . maybe noop (`throwTo` PauseWatcher) =<< liftAssistant (namedThreadId watchThread)
|
||||
liftIO . nukeFile =<< liftAnnex (fromRepo gitAnnexUrlFile)
|
||||
liftIO . nukeFile =<< liftAnnex (fromRepo gitAnnexPidFile)
|
||||
ret <- switchToAssistant =<< liftAnnex (repoLocation <$> Annex.gitRepo)
|
||||
void . liftIO . forkIO =<< liftAssistant (asIO reaper)
|
||||
return ret
|
||||
reapself `after` startnewprocess
|
||||
where
|
||||
-- Wait for the redirect to be served to the browser
|
||||
-- before terminating this process.
|
||||
reaper = do
|
||||
liftIO $ threadDelaySeconds (Seconds 120)
|
||||
liftIO $ exitSuccess
|
||||
reapself = liftIO $ void $ forkIO $ do
|
||||
threadDelaySeconds (Seconds 120)
|
||||
signalProcess sigTERM =<< getProcessID
|
||||
startnewprocess = switchToAssistant
|
||||
=<< liftAnnex (repoLocation <$> Annex.gitRepo)
|
||||
|
|
Loading…
Reference in a new issue