# HG changeset patch # User Drew Perttula # Date 1433750503 0 # Node ID 70f42f9d6e04844210a045be5d6f9faa0a317537 # Parent 42656c3b31f44e75da08c8b11f6c349f692fe79d simplify homepageConfig. get homepage port from rdf. get rdfdb port from rdf Ignore-this: 385f637df1b0d670a182d492f151a163 diff -r 42656c3b31f4 -r 70f42f9d6e04 bin/homepage --- 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 diff -r 42656c3b31f4 -r 70f42f9d6e04 bin/homepageConfig --- 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() diff -r 42656c3b31f4 -r 70f42f9d6e04 bin/rdfdb --- 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)