4904: Chooses most recently modified collection and runs web service on it.
authorPeter Amstutz <peter.amstutz@curoverse.com>
Wed, 14 Jan 2015 20:21:04 +0000 (15:21 -0500)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Wed, 14 Jan 2015 20:21:04 +0000 (15:21 -0500)
Dockerfile [new file with mode: 0644]
apache2_foreground.sh [new file with mode: 0755]
apache2_vhost [new file with mode: 0644]
runit.py

diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..9f2c62b
--- /dev/null
@@ -0,0 +1,20 @@
+FROM arvados/base
+MAINTAINER Peter Amstutz <peter.amstutz@curoverse.com>
+
+RUN apt-get update -qq
+RUN apt-get install -qqy \
+        apt-utils git curl procps apache2-mpm-worker \
+        libcurl4-openssl-dev apache2-threaded-dev \
+        libapr1-dev libaprutil1-dev
+
+# Install apache configuration...
+
+ADD apache2_vhost /etc/apache2/sites-available/arv-web
+RUN \
+  a2dissite default && \
+  a2ensite arv-web && \
+  a2enmod rewrite
+
+ADD apache2_foreground.sh /etc/apache2/foreground.sh
+
+CMD ["/etc/apache2/foreground.sh"]
\ No newline at end of file
diff --git a/apache2_foreground.sh b/apache2_foreground.sh
new file mode 100755 (executable)
index 0000000..fc6028e
--- /dev/null
@@ -0,0 +1,7 @@
+#! /bin/bash
+
+read pid cmd state ppid pgrp session tty_nr tpgid rest < /proc/self/stat
+trap "kill -TERM -$pgrp; exit" EXIT TERM KILL SIGKILL SIGTERM SIGQUIT
+
+source /etc/apache2/envvars
+/usr/sbin/apache2 -D FOREGROUND
diff --git a/apache2_vhost b/apache2_vhost
new file mode 100644 (file)
index 0000000..bb5e58c
--- /dev/null
@@ -0,0 +1,21 @@
+<VirtualHost *:80>
+
+  ServerName arv-web
+  ServerAdmin sysadmin@curoverse.com
+
+  # Index file and Document Root (where the public files are located)
+  DirectoryIndex index.html
+  DocumentRoot /mnt
+
+  LogLevel warn
+  ErrorLog  ${APACHE_LOG_DIR}/error.log
+  CustomLog ${APACHE_LOG_DIR}/access.log combined
+
+  <Directory /mnt>
+    Options Indexes FollowSymLinks MultiViews IncludesNoExec
+    AllowOverride None
+    Order allow,deny
+    allow from all
+  </Directory>
+
+</VirtualHost>
index 2a940271d6ef8400403b40a9e2f6e632b9ef5174..80111588bea92058895a1c7cced847b61ce76c87 100644 (file)
--- a/runit.py
+++ b/runit.py
@@ -1,6 +1,6 @@
 import arvados
 import subprocess
-from arvados_fuse import Operations, SafeApi, MagicDirectory
+from arvados_fuse import Operations, SafeApi, CollectionDirectory
 import tempfile
 import os
 import llfuse
@@ -42,21 +42,25 @@ def on_message(ev):
     global project
     global evqueue
 
-    old_attr = None
-    if 'old_attributes' in ev['properties'] and ev['properties']['old_attributes']:
-        old_attr = ev['properties']['old_attributes']
-    if project not in (ev['properties']['new_attributes']['owner_uuid'],
-                            old_attr['owner_uuid'] if old_attr else None):
-        return
-
-    et = ev['event_type']
-    if ev['event_type'] == 'update' and ev['properties']['new_attributes']['owner_uuid'] != ev['properties']['old_attributes']['owner_uuid']:
-        if args.project == ev['properties']['new_attributes']['owner_uuid']:
-            et = 'add'
-        else:
-            et = 'remove'
-
-    evqueue.put((project, et, ev['object_uuid']))
+    import pprint
+    pprint.pprint(ev)
+
+    if 'event_type' in ev:
+        old_attr = None
+        if 'old_attributes' in ev['properties'] and ev['properties']['old_attributes']:
+            old_attr = ev['properties']['old_attributes']
+        if project not in (ev['properties']['new_attributes']['owner_uuid'],
+                                old_attr['owner_uuid'] if old_attr else None):
+            return
+
+        et = ev['event_type']
+        if ev['event_type'] == 'update' and ev['properties']['new_attributes']['owner_uuid'] != ev['properties']['old_attributes']['owner_uuid']:
+            if args.project == ev['properties']['new_attributes']['owner_uuid']:
+                et = 'add'
+            else:
+                et = 'remove'
+
+        evqueue.put((project, et, ev['object_uuid']))
 
 filters = [['owner_uuid', '=', project],
            ['uuid', 'is_a', 'arvados#collection']]