summaryrefslogtreecommitdiff
path: root/Assistant/Threads
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-11-23 14:47:38 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-11-23 14:47:38 -0400
commit4d526e2938b131421b0760ac2f90b4a0ffec2df8 (patch)
treed7ad6cf052b66d35c3a5665da05817f90c45a60a /Assistant/Threads
parent3e72d35e75dccdcd4b498e6b30a5ad9b1c448a71 (diff)
global webapp redirects, to finish upgrades
When an automatic upgrade completes, or when the user clicks on the upgrade button in one webapp, but also has it open in another browser window/tab, we have a problem: The current web server is going to stop running in minutes, but there is no way to send a redirect to the web browser to the new url. To solve this, used long polling, so the webapp is always listening for urls it should redirect to. This allows globally redirecting every open webapp. Works great! Tested with 2 web browsers with 2 tabs each. May be useful for other purposes later too, dunno. The overhead is 2 http requests per page load in the webapp. Due to yesod's speed, this does not seem to noticibly delay it. Only 1 of the requests could possibly block the page load, the other is async.
Diffstat (limited to 'Assistant/Threads')
-rw-r--r--Assistant/Threads/UpgradeWatcher.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/Assistant/Threads/UpgradeWatcher.hs b/Assistant/Threads/UpgradeWatcher.hs
index 7cb42e597..6122d2535 100644
--- a/Assistant/Threads/UpgradeWatcher.hs
+++ b/Assistant/Threads/UpgradeWatcher.hs
@@ -25,8 +25,6 @@ import Assistant.DaemonStatus
import Assistant.WebApp.Types
import qualified Build.SysConfig
#endif
-import qualified Annex
-import Types.Distribution
import Control.Concurrent.MVar
import Data.Tuple.Utils
@@ -102,7 +100,7 @@ handleUpgrade urlrenderer = do
-- (For example, other associated files may be being put into
-- place.)
liftIO $ threadDelaySeconds (Seconds 120)
- ifM (liftAnnex $ (==) AutoUpgrade . annexAutoUpgrade <$> Annex.getGitConfig)
+ ifM autoUpgradeEnabled
( do
debug ["starting automatic upgrade"]
unattendedUpgrade
@@ -118,9 +116,12 @@ handleUpgrade urlrenderer = do
showSuccessfulUpgrade :: UrlRenderer -> Assistant ()
showSuccessfulUpgrade urlrenderer = do
#ifdef WITH_WEBAPP
- button <- mkAlertButton True
- (T.pack "Enable Automatic Upgrades")
- urlrenderer ConfigEnableAutomaticUpgradeR
+ button <- ifM autoUpgradeEnabled
+ ( pure Nothing
+ , Just <$> mkAlertButton True
+ (T.pack "Enable Automatic Upgrades")
+ urlrenderer ConfigEnableAutomaticUpgradeR
+ )
void $ addAlert $ upgradeFinishedAlert button Build.SysConfig.packageversion
#else
noop