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
|
- 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. -}
|
- run by git-annex to be passed parameters that override this setting. -}
|
||||||
fixupDirect :: Git.Repo -> Git.Repo
|
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
|
r
|
||||||
{ location = Local { gitdir = d </> ".git", worktree = Just d }
|
{ location = l { worktree = Just (parentDir d) }
|
||||||
, gitGlobalOpts = gitGlobalOpts r ++
|
, gitGlobalOpts = gitGlobalOpts r ++
|
||||||
[ Param "-c"
|
[ Param "-c"
|
||||||
, Param $ coreBare ++ "=" ++ boolConfig False
|
, Param $ coreBare ++ "=" ++ boolConfig False
|
||||||
|
|
|
@ -23,6 +23,7 @@ import Git
|
||||||
|
|
||||||
import Data.Time.Clock
|
import Data.Time.Clock
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
|
import System.Posix (getProcessID, signalProcess, sigTERM)
|
||||||
|
|
||||||
getConfigStartUpgradeR :: GitAnnexDistribution -> Handler Html
|
getConfigStartUpgradeR :: GitAnnexDistribution -> Handler Html
|
||||||
getConfigStartUpgradeR d = page "Upgrade git-annex" (Just Configuration) $ do
|
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
|
- gitAnnexUrlFile and our gitAnnexPidFile. Pausing the watcher is also
|
||||||
- a good idea, to avoid fighting when two assistants are running in the
|
- a good idea, to avoid fighting when two assistants are running in the
|
||||||
- same repo.
|
- 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 :: Handler Html
|
||||||
getConfigFinishUpgradeR = do
|
getConfigFinishUpgradeR = do
|
||||||
|
@ -45,12 +51,12 @@ getConfigFinishUpgradeR = do
|
||||||
liftIO . maybe noop (`throwTo` PauseWatcher) =<< liftAssistant (namedThreadId watchThread)
|
liftIO . maybe noop (`throwTo` PauseWatcher) =<< liftAssistant (namedThreadId watchThread)
|
||||||
liftIO . nukeFile =<< liftAnnex (fromRepo gitAnnexUrlFile)
|
liftIO . nukeFile =<< liftAnnex (fromRepo gitAnnexUrlFile)
|
||||||
liftIO . nukeFile =<< liftAnnex (fromRepo gitAnnexPidFile)
|
liftIO . nukeFile =<< liftAnnex (fromRepo gitAnnexPidFile)
|
||||||
ret <- switchToAssistant =<< liftAnnex (repoLocation <$> Annex.gitRepo)
|
reapself `after` startnewprocess
|
||||||
void . liftIO . forkIO =<< liftAssistant (asIO reaper)
|
|
||||||
return ret
|
|
||||||
where
|
where
|
||||||
-- Wait for the redirect to be served to the browser
|
-- Wait for the redirect to be served to the browser
|
||||||
-- before terminating this process.
|
-- before terminating this process.
|
||||||
reaper = do
|
reapself = liftIO $ void $ forkIO $ do
|
||||||
liftIO $ threadDelaySeconds (Seconds 120)
|
threadDelaySeconds (Seconds 120)
|
||||||
liftIO $ exitSuccess
|
signalProcess sigTERM =<< getProcessID
|
||||||
|
startnewprocess = switchToAssistant
|
||||||
|
=<< liftAnnex (repoLocation <$> Annex.gitRepo)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue