diff --git a/bin/homepage b/bin/homepage --- a/bin/homepage +++ b/bin/homepage @@ -21,7 +21,6 @@ http { include $ROOT/light9/web/mime.types; server { - listen 8054; access_log off; include "/tmp/light9_nginx_routes.conf"; @@ -33,5 +32,5 @@ http { } } EOF - +head -1 /tmp/light9_nginx_routes.conf exec nginx -c $CONF diff --git a/bin/homepageConfig b/bin/homepageConfig --- a/bin/homepageConfig +++ b/bin/homepageConfig @@ -3,34 +3,33 @@ from run_local import log 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 --git a/bin/rdfdb b/bin/rdfdb --- a/bin/rdfdb +++ b/bin/rdfdb @@ -421,8 +421,7 @@ if __name__ == "__main__": 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 @@ if __name__ == "__main__": "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)