##// END OF EJS Templates
hgweb: make refresh interval configurable...
Gregory Szorc -
r26072:06320fb1 default
parent child Browse files
Show More
@@ -1752,6 +1752,14 b' The full set of options is:'
1752 1752 Whether to require that inbound pushes be transported over SSL to
1753 1753 prevent password sniffing. Default is True.
1754 1754
1755 ``refreshinterval``
1756 How frequently directory listings re-scan the filesystem for new
1757 repositories, in seconds. This is relevant when wildcards are used
1758 to define paths. Depending on how much filesystem traversal is
1759 required, refreshing may negatively impact performance.
1760
1761 Default is 20. Values less than or equal to 0 always refresh.
1762
1755 1763 ``staticurl``
1756 1764 Base URL to use for static files. If unset, static files (e.g. the
1757 1765 hgicon.png favicon) will be served by the CGI script itself. Use
@@ -79,17 +79,23 b' def geturlcgivars(baseurl, port):'
79 79 return name, str(port), path
80 80
81 81 class hgwebdir(object):
82 refreshinterval = 20
83
84 82 def __init__(self, conf, baseui=None):
85 83 self.conf = conf
86 84 self.baseui = baseui
85 self.ui = None
87 86 self.lastrefresh = 0
88 87 self.motd = None
89 88 self.refresh()
90 89
91 90 def refresh(self):
92 if self.lastrefresh + self.refreshinterval > time.time():
91 refreshinterval = 20
92 if self.ui:
93 refreshinterval = self.ui.configint('web', 'refreshinterval',
94 refreshinterval)
95
96 # refreshinterval <= 0 means to always refresh.
97 if (refreshinterval > 0 and
98 self.lastrefresh + refreshinterval > time.time()):
93 99 return
94 100
95 101 if self.baseui:
@@ -1245,6 +1245,67 b' rss-log with basedir /foo/'
1245 1245 $ get-with-headers.py localhost:$HGPORT2 'a/rss-log' | grep '<guid'
1246 1246 <guid isPermaLink="true">http://hg.example.com:8080/foo/a/rev/8580ff50825a</guid>
1247 1247
1248 Path refreshing works as expected
1249
1250 $ killdaemons.py
1251 $ mkdir $root/refreshtest
1252 $ hg init $root/refreshtest/a
1253 $ cat > paths.conf << EOF
1254 > [paths]
1255 > / = $root/refreshtest/*
1256 > EOF
1257 $ hg serve -p $HGPORT1 -d --pid-file hg.pid --webdir-conf paths.conf
1258 $ cat hg.pid >> $DAEMON_PIDS
1259
1260 $ get-with-headers.py localhost:$HGPORT1 '?style=raw'
1261 200 Script output follows
1262
1263
1264 /a/
1265
1266
1267 By default refreshing occurs every 20s and a new repo won't be listed
1268 immediately.
1269
1270 $ hg init $root/refreshtest/b
1271 $ get-with-headers.py localhost:$HGPORT1 '?style=raw'
1272 200 Script output follows
1273
1274
1275 /a/
1276
1277
1278 Restart the server with no refresh interval. New repo should appear
1279 immediately.
1280
1281 $ killdaemons.py
1282 $ cat > paths.conf << EOF
1283 > [web]
1284 > refreshinterval = -1
1285 > [paths]
1286 > / = $root/refreshtest/*
1287 > EOF
1288 $ hg serve -p $HGPORT1 -d --pid-file hg.pid --webdir-conf paths.conf
1289 $ cat hg.pid >> $DAEMON_PIDS
1290
1291 $ get-with-headers.py localhost:$HGPORT1 '?style=raw'
1292 200 Script output follows
1293
1294
1295 /a/
1296 /b/
1297
1298
1299 $ hg init $root/refreshtest/c
1300 $ get-with-headers.py localhost:$HGPORT1 '?style=raw'
1301 200 Script output follows
1302
1303
1304 /a/
1305 /b/
1306 /c/
1307
1308
1248 1309 paths errors 1
1249 1310
1250 1311 $ cat error-paths-1.log
General Comments 0
You need to be logged in to leave comments. Login now