changeset 1215:0d295af23c4b

new nginx router Ignore-this: 6124717ecb304709d4662b58a1e9ed71
author Drew Perttula <drewp@bigasterisk.com>
date Mon, 08 Jun 2015 00:38:08 +0000
parents 22e6a47448a3
children 896979e6f352
files bin/homepage bin/homepageConfig bin/run_local.py light9/showconfig.py show/dance2014/networking.n3
diffstat 5 files changed, 44 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/bin/homepage	Mon Jun 08 00:37:26 2015 +0000
+++ b/bin/homepage	Mon Jun 08 00:38:08 2015 +0000
@@ -4,6 +4,8 @@
 ROOT=`dirname $0`/..
 ROOT=${ROOT:a}
 
+bin/homepageConfig > /tmp/light9_nginx_routes.conf
+
 cat > $CONF <<EOF
 worker_processes 1;
 
@@ -19,11 +21,10 @@
  include $ROOT/light9/web/mime.types;
  
  server {
-  listen 8052;
-  access_log /tmp/light9_homepage_access.log;
+  listen 8054;
+  access_log off;
 
-  location /rdfdb { proxy_pass http://localhost:8051/; }
-  location /ascoltami { proxy_pass http://localhost:8040/; rewrite /ascoltami(.*) $1 break; }
+  include "/tmp/light9_nginx_routes.conf";
 
   location / {
     root $ROOT/light9/web;
--- /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()
--- a/bin/run_local.py	Mon Jun 08 00:37:26 2015 +0000
+++ b/bin/run_local.py	Mon Jun 08 00:38:08 2015 +0000
@@ -41,7 +41,7 @@
     if os.environ.get('TERM', '') in ['xterm', 'rxvt']:
         print "\033]0;%s\007" % s # not escaped/protected correctly
 
-if 'listsongs' not in sys.argv[0]:
+if 'listsongs' not in sys.argv[0] and 'homepageConfig' not in sys.argv[0]:
     setTerminalTitle('[%s] %s' % (socket.gethostname(), ' '.join(sys.argv)))
 
 # see http://www.youtube.com/watch?v=3cIOT9kM--g for commands that make
--- a/light9/showconfig.py	Mon Jun 08 00:37:26 2015 +0000
+++ b/light9/showconfig.py	Mon Jun 08 00:38:08 2015 +0000
@@ -15,9 +15,8 @@
         graph = Graph()
         # note that logging is probably not configured the first time
         # we're in here
-        print "reading n3 files around %r" % root()
+        warnings.warn("reading n3 files around %r" % root())
         for f in FilePath(root()).globChildren("*.n3") + FilePath(root()).globChildren("build/*.n3"):
-            print "reading %s" % f
             graph.parse(location=f.path, format='n3')
         _config = graph
     return _config
--- a/show/dance2014/networking.n3	Mon Jun 08 00:37:26 2015 +0000
+++ b/show/dance2014/networking.n3	Mon Jun 08 00:38:08 2015 +0000
@@ -14,4 +14,15 @@
   :keyboardComposer <http://plus:8050/>;
   :subComposer <http://plus:8054/>;
   :picamserve       <http://10.2.0.3:8001/>;
-  :vidref           <http://plus:8053/> .
+  :vidref           <http://dash:8053/> .
+
+:rdfdb            :urlPath "rdfdb" .
+:effectEval       :urlPath "effectEval" .
+:musicPlayer      :urlPath "ascoltami" .
+:dmxServer        :urlPath "dmxServer" .
+:oscDmxServer     :urlPath "oscDmxServer" .
+:curveCalc        :urlPath "curveCalc" .
+:keyboardComposer :urlPath "keyboardComposer" .
+:subComposer      :urlPath "subComposer" .
+:picamserve       :urlPath "picamserve" .
+:vidref           :urlPath "vidref" .