[manual] Add get_events URL routing

The new nginx configuration file needs to be copied to
/etc/nginx/humbug-include and nginx needs to be restarted when this
commit is deployed.

(imported from commit 6c43f3c2c7a6acee6a852c672c96a38bda01dd0d)
This commit is contained in:
Zev Benjamin 2013-03-26 13:06:52 -04:00
parent 8f4eaa63ad
commit 401fa6063e
4 changed files with 8 additions and 3 deletions

View File

@ -144,6 +144,8 @@ urlpatterns += patterns('zephyr.tornadoviews',
url(r'^api/v1/get_messages$', 'api_get_messages'), url(r'^api/v1/get_messages$', 'api_get_messages'),
url(r'^api/v1/messages/latest$', 'rest_get_messages'), url(r'^api/v1/messages/latest$', 'rest_get_messages'),
url(r'^json/get_updates$', 'json_get_updates'), url(r'^json/get_updates$', 'json_get_updates'),
url(r'^api/v1/events$', 'rest_get_events'),
url(r'^json/get_events$', 'json_get_events'),
# Used internally for communication between Django and Tornado processes # Used internally for communication between Django and Tornado processes
url(r'^notify_tornado$', 'notify'), url(r'^notify_tornado$', 'notify'),
) )

View File

@ -14,7 +14,7 @@ location /static/ {
} }
# Send longpoll requests to Tornado # Send longpoll requests to Tornado
location ~ /json/get_updates|/api/v1/get_messages|/api/v1/messages/latest { location ~ /json/get_updates|/api/v1/get_messages|/api/v1/messages/latest|/json/get_events|/api/v1/events {
proxy_pass http://localhost:9993; proxy_pass http://localhost:9993;
proxy_redirect off; proxy_redirect off;

View File

@ -61,8 +61,9 @@ class Resource(resource.Resource):
def getChild(self, name, request): def getChild(self, name, request):
request.requestHeaders.setRawHeaders('X-Forwarded-Host', [proxy_host]) request.requestHeaders.setRawHeaders('X-Forwarded-Host', [proxy_host])
if request.uri in ['/json/get_updates', '/api/v1/get_messages'] or \ if (request.uri in ['/json/get_updates', '/api/v1/get_messages', '/json/get_events'] or
request.uri.startswith('/api/v1/messages/latest'): request.uri.startswith('/api/v1/messages/latest') or
request.uri.startswith('/api/v1/events')):
return proxy.ReverseProxyResource('localhost', tornado_port, '/'+name) return proxy.ReverseProxyResource('localhost', tornado_port, '/'+name)
return proxy.ReverseProxyResource('localhost', django_port, '/'+name) return proxy.ReverseProxyResource('localhost', django_port, '/'+name)

View File

@ -87,6 +87,8 @@ class Command(BaseCommand):
r"/api/v1/get_messages", r"/api/v1/get_messages",
r"/notify_tornado", r"/notify_tornado",
r"/api/v1/messages/latest", r"/api/v1/messages/latest",
r"/json/get_events",
r"/api/v1/events",
) )
# Application is an instance of Django's standard wsgi handler. # Application is an instance of Django's standard wsgi handler.
application = web.Application([(url, AsyncDjangoHandler) for url in urls], application = web.Application([(url, AsyncDjangoHandler) for url in urls],