+// The timer used to touch the file every 30 seconds if nobody
+// else does it for us. This makes sure we don't have clients
+// hanging indefinitely (which might have them return errors).
+var touch_timer = undefined;
+
+// If we are behind Varnish, we can't count the number of clients
+// ourselves, so some external log-tailing daemon needs to tell us.
+var viewer_count_override = undefined;
+
+var replace_json = function(new_json_contents, mtime) {
+ var new_json = {
+ parsed: JSON.parse(new_json_contents),
+ plain: new_json_contents,
+ last_modified: mtime
+ };
+
+ // gzip the new version, and put it into place.
+ zlib.gzip(new_json_contents, function(err, buffer) {
+ if (err) throw err;
+
+ new_json.gzip = buffer;
+ json = new_json;
+
+ // Finally, wake up any sleeping clients.
+ possibly_wakeup_clients();
+ });
+}
+