Changeset - 70f42f9d6e04
[Not reviewed]
default
0 3 0
Drew Perttula - 10 years ago 2015-06-08 08:01:43
drewp@bigasterisk.com
simplify homepageConfig. get homepage port from rdf. get rdfdb port from rdf
Ignore-this: 385f637df1b0d670a182d492f151a163
3 files changed with 25 insertions and 28 deletions:
0 comments (0 inline, 0 general)
bin/homepage
Show inline comments
 
@@ -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
bin/homepageConfig
Show inline comments
 
@@ -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()
bin/rdfdb
Show inline comments
 
@@ -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)
0 comments (0 inline, 0 general)