assistant: Detect when repository has been deleted or moved, and automatically shut down the assistant. Closes: #761261

This commit is contained in:
Joey Hess 2014-09-15 14:45:37 -04:00
parent 4e3d176b1b
commit 09e20c3827
4 changed files with 24 additions and 6 deletions

View file

@ -53,6 +53,10 @@ postRestart url = do
liftIO . sendNotification . globalRedirNotifier =<< getDaemonStatus
void $ liftIO $ forkIO $ do
threadDelaySeconds (Seconds 120)
terminateSelf
terminateSelf :: IO ()
terminateSelf =
#ifndef mingw32_HOST_OS
signalProcess sigTERM =<< getPID
#else

View file

@ -21,7 +21,9 @@ import Assistant.Drop
import Assistant.Ssh
import Assistant.TransferQueue
import Assistant.Types.UrlRenderer
import Assistant.Restart
import qualified Annex.Branch
import qualified Git
import qualified Git.LsFiles
import qualified Git.Command.Batch
import qualified Git.Config
@ -146,6 +148,8 @@ waitForNextCheck = do
- will block the watcher. -}
dailyCheck :: UrlRenderer -> Assistant Bool
dailyCheck urlrenderer = do
checkRepoExists
g <- liftAnnex gitRepo
batchmaker <- liftIO getBatchCommandMaker
@ -203,6 +207,7 @@ dailyCheck urlrenderer = do
hourlyCheck :: Assistant ()
hourlyCheck = do
checkRepoExists
#ifndef mingw32_HOST_OS
checkLogSize 0
#else
@ -316,3 +321,9 @@ cleanOld check f = go =<< catchMaybeIO getmtime
getmtime = realToFrac . modificationTime <$> getSymbolicLinkStatus f
go (Just mtime) | check mtime = nukeFile f
go _ = noop
checkRepoExists :: Assistant ()
checkRepoExists = do
g <- liftAnnex gitRepo
liftIO $ unlessM (doesDirectoryExist $ Git.repoPath g) $
terminateSelf

View file

@ -53,15 +53,11 @@ getShutdownConfirmedR = do
- page time to load in the browser. -}
void $ liftIO $ forkIO $ do
threadDelay 2000000
#ifndef mingw32_HOST_OS
signalProcess sigTERM =<< getPID
#else
terminatePID =<< getPID
#endif
terminateSelf
redirect NotRunningR
{- Use a custom page to avoid putting long polling elements on it that will
- fail and cause the web browser to show an error once the webapp is
- fail and cause thet web browser to show an error once the webapp is
- truely stopped. -}
getNotRunningR :: Handler Html
getNotRunningR = customPage' False Nothing $

7
debian/changelog vendored
View file

@ -1,3 +1,10 @@
git-annex (5.20140916) UNRELEASED; urgency=medium
* assistant: Detect when repository has been deleted or moved, and
automatically shut down the assistant. Closes: #761261
-- Joey Hess <joeyh@debian.org> Mon, 15 Sep 2014 14:39:17 -0400
git-annex (5.20140915) unstable; urgency=medium
* New annex.hardlink setting. Closes: #758593