diff bin/homepageConfig @ 1215:0d295af23c4b

new nginx router Ignore-this: 6124717ecb304709d4662b58a1e9ed71
author Drew Perttula <drewp@bigasterisk.com>
date Mon, 08 Jun 2015 00:38:08 +0000
parents
children e703b3434dbd
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/homepageConfig	Mon Jun 08 00:38:08 2015 +0000
@@ -0,0 +1,25 @@
+#!bin/python
+from run_local import log
+from rdflib import RDF, URIRef
+from light9 import networking, showconfig
+from light9.namespaces import L9
+
+from light9.rdfdb.syncedgraph import SyncedGraph
+from twisted.internet import reactor
+
+graph = SyncedGraph(networking.rdfdb.url, "homepageConfig")
+
+@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 { proxy_pass %(server)s; rewrite /[^/]+/(.*) /$1 break; }" % vars()
+
+    reactor.stop()
+
+reactor.run()