Mercurial > code > home > repos > light9
changeset 1225:70f42f9d6e04
simplify homepageConfig. get homepage port from rdf. get rdfdb port from rdf
Ignore-this: 385f637df1b0d670a182d492f151a163
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Mon, 08 Jun 2015 08:01:43 +0000 |
parents | 42656c3b31f4 |
children | 1ea0629a7fe6 |
files | bin/homepage bin/homepageConfig bin/rdfdb |
diffstat | 3 files changed, 25 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/homepage Mon Jun 08 08:00:47 2015 +0000 +++ b/bin/homepage Mon Jun 08 08:01:43 2015 +0000 @@ -21,7 +21,6 @@ include $ROOT/light9/web/mime.types; server { - listen 8054; access_log off; include "/tmp/light9_nginx_routes.conf"; @@ -33,5 +32,5 @@ } } EOF - +head -1 /tmp/light9_nginx_routes.conf exec nginx -c $CONF
--- a/bin/homepageConfig Mon Jun 08 08:00:47 2015 +0000 +++ b/bin/homepageConfig Mon Jun 08 08:01:43 2015 +0000 @@ -3,34 +3,33 @@ from rdflib import RDF, URIRef from light9 import networking, showconfig from light9.namespaces import L9 +from urlparse import urlparse +from urllib import splitport from light9.rdfdb.syncedgraph import SyncedGraph from twisted.internet import reactor -graph = SyncedGraph(networking.rdfdb.url, "homepageConfig") +graph = showconfig.getGraph() -@graph.initiallySynced.addCallback -def printConfig(result): - with graph.currentState() as current: - netHome = current.value(showconfig.showUri(), L9['networking']) - for role, server in current.predicate_objects(netHome): - if not server.startswith('http'): - continue - path = current.value(role, L9['urlPath']) - server = server.rstrip('/') - print """ - location /%(path)s { +netHome = graph.value(showconfig.showUri(), L9['networking']) +print "listen %s;" % splitport(urlparse(graph.value(netHome, L9['webServer'])).netloc)[1] - # for websocket - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; +for role, server in graph.predicate_objects(netHome): + if not server.startswith('http') or role == L9['webServer']: + continue + path = graph.value(role, L9['urlPath']) + if not path: + continue + server = server.rstrip('/') + print """ + location /%(path)s { - proxy_pass %(server)s; - rewrite /[^/]+/(.*) /$1 break; - }""" % vars() + # for websocket + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; - reactor.stop() - -reactor.run() + proxy_pass %(server)s; + rewrite /[^/]+/(.*) /$1 break; + }""" % vars()
--- a/bin/rdfdb Mon Jun 08 08:00:47 2015 +0000 +++ b/bin/rdfdb Mon Jun 08 08:01:43 2015 +0000 @@ -421,8 +421,7 @@ from twisted.python import log as twlog twlog.startLogging(sys.stdout) - port = 8051 - reactor.listenTCP(port, cyclone.web.Application(handlers=[ + reactor.listenTCP(networking.rdfdb.port, cyclone.web.Application(handlers=[ (r'/live', Live), (r'/graph', GraphResource), (r'/patches', Patches), @@ -433,5 +432,5 @@ "default_filename" : "index.xhtml"}), ], debug=True, db=db)) - log.info("serving on %s" % port) + log.info("serving on %s" % networking.rdfdb.port) prof.run(reactor.run, profile=None)