Browse Source

Add last updated time

master
Chris Smith 8 years ago
parent
commit
de884d91f0
2 changed files with 12 additions and 2 deletions
  1. 6
    2
      README.md
  2. 6
    0
      updater.py

+ 6
- 2
README.md View File

@@ -64,10 +64,14 @@ networks in etcd:
64 64
                 /{network2}/...
65 65
 ```
66 66
 
67
+There is also a special node at `/docker/_updated` which is updated with
68
+the current unix timestamp after an update has finished. This may be useful
69
+to watch in scripts that need to trigger after container changes (listening
70
+to the containers would trigger as soon as the first child node is written,
71
+so is probably not useful in most situations).
72
+
67 73
 ## Current known issues
68 74
 
69 75
 * The docker node is deleted when the script starts, so you can't run multiple
70 76
   copies on multiple hosts
71
-* There's no way to get notified when the script has finished, rather than
72
-  mid-update
73 77
 

+ 6
- 0
updater.py View File

@@ -1,6 +1,7 @@
1 1
 #!/usr/bin/env python3
2 2
 
3 3
 import etcd
4
+import time
4 5
 
5 6
 
6 7
 class Updater:
@@ -44,6 +45,7 @@ class Updater:
44 45
       for k, v in container['net']['addr'].items():
45 46
         self._write('/networks/%s/%s' % (k, name), v)
46 47
       self._write('/hosts/%s/%s' % (container['host'], name), name)
48
+    self._notify_update()
47 49
 
48 50
 
49 51
   def remove_containers(self, old_containers):
@@ -55,4 +57,8 @@ class Updater:
55 57
       for k, v in container['net']['addr'].items():
56 58
         self._delete('/networks/%s/%s' % (k, name)) 
57 59
       self._delete('/hosts/%s/%s' % (container['host'], name))
60
+    self._notify_update()
61
+
62
+  def _notify_update(self):
63
+    self._write('/_updated', time.time())
58 64
 

Loading…
Cancel
Save