From: Radek Czajka Date: Mon, 7 Jun 2010 12:26:46 +0000 (+0200) Subject: ping server every 10 minutes X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/404bfe407798a8a83fa02dc1742a315400b7c00b?ds=sidebyside;hp=-c ping server every 10 minutes --- 404bfe407798a8a83fa02dc1742a315400b7c00b diff --git a/apps/wiki/urls.py b/apps/wiki/urls.py index bfc799f5..e4e0deb3 100644 --- a/apps/wiki/urls.py +++ b/apps/wiki/urls.py @@ -26,4 +26,6 @@ urlpatterns = patterns('wiki.views', url(r'^(?P[^/]+)$', 'document_detail', name="wiki_details"), + + url(r'^ping/$', 'ping', name='ping'), ) diff --git a/apps/wiki/views.py b/apps/wiki/views.py index 46f0665f..c5fd80e3 100644 --- a/apps/wiki/views.py +++ b/apps/wiki/views.py @@ -256,3 +256,7 @@ def document_publish(request, name): return JSONResponse({"result": api.publish_book(document)}) except wlapi.APICallException, e: return JSONServerError({"message": str(e)}) + + +def ping(request): + return http.HttpResponse('pong') diff --git a/redakcja/static/js/wiki/wikiapi.js b/redakcja/static/js/wiki/wikiapi.js index 26732bd5..13435ea0 100644 --- a/redakcja/static/js/wiki/wikiapi.js +++ b/redakcja/static/js/wiki/wikiapi.js @@ -44,6 +44,9 @@ if (vname == "ajax_publish") return base_path + "/" + arguments[1] + "/publish"; + + if (vname == 'ping') + return base_path + '/ping/' console.log("Couldn't reverse match:", vname); return "/404.html"; @@ -320,4 +323,20 @@ }; $.wikiapi.WikiDocument = WikiDocument; + + + var ping = function () { + $.ajax({ + url : reverse('ping'), + timeout: 2000, + complete : function () { + setTimeout(function () { + ping(); + }, 600000); + } + }); + }; + + ping(); + })(jQuery);