]> git.openstreetmap.org Git - chef.git/commitdiff
Merge remote-tracking branch 'github/pull/89'
authorTom Hughes <tom@compton.nu>
Wed, 7 Sep 2016 10:34:05 +0000 (11:34 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 7 Sep 2016 10:34:05 +0000 (11:34 +0100)
cookbooks/planet/files/default/flush/Makefile [new file with mode: 0644]
cookbooks/planet/files/default/flush/flush.c [new file with mode: 0644]
cookbooks/planet/recipes/replication.rb
cookbooks/planet/templates/default/replication.cron.erb

diff --git a/cookbooks/planet/files/default/flush/Makefile b/cookbooks/planet/files/default/flush/Makefile
new file mode 100644 (file)
index 0000000..b42035e
--- /dev/null
@@ -0,0 +1,2 @@
+flush.so: flush.c
+       cc -O2 -fPIC -D_GNU_SOURCE -shared -o flush.so flush.c -ldl
diff --git a/cookbooks/planet/files/default/flush/flush.c b/cookbooks/planet/files/default/flush/flush.c
new file mode 100644 (file)
index 0000000..c80e86a
--- /dev/null
@@ -0,0 +1,16 @@
+#include <dlfcn.h>
+#include <unistd.h>
+
+static int (*real_close)(int fd);
+
+static void __attribute__((constructor)) initialise(void)
+{
+  real_close = dlsym(RTLD_NEXT, "close");
+}
+
+int close(int fd)
+{
+  fdatasync(fd);
+
+  return real_close(fd);
+}
index d9ff9b67c04cfae7bb0dba9d47482b16f71cef22..25fe9671da5e4e186293a2cf8a35df600c677358 100644 (file)
@@ -30,6 +30,28 @@ package "ruby-libxml"
 package "libpq-dev"
 gem_package "pg"
 
+package "make"
+package "gcc"
+
+remote_directory "/opt/flush" do
+  source "flush"
+  owner "root"
+  group "root"
+  mode 0o755
+  files_owner "root"
+  files_group "root"
+  files_mode 0o755
+end
+
+execute "/opt/flush/Makefile" do
+  action :nothing
+  command "make"
+  cwd "/opt/flush"
+  user "root"
+  group "root"
+  subscribes :run, "remote_directory[/opt/flush]"
+end
+
 remote_directory "/usr/local/bin" do
   source "replication-bin"
   owner "root"
index 439de398348f9905e232c106208626be7e6d3c4a..84ee83c7cc196eb416e07ac455cdfd04e2995452 100644 (file)
@@ -2,13 +2,14 @@
 
 TZ=UTC
 
+MAILTO=zerebubuth@gmail.com
+
+0 7 * * * planet /usr/local/bin/users-agreed
+* * * * * planet /usr/local/bin/replicate-changesets /etc/replication/changesets.conf
+
 MAILTO=brett@bretth.com
+LD_PRELOAD=/opt/flush/flush.so
 
 * * * * * planet /usr/local/bin/osmosis -q --replicate-apidb authFile=/etc/replication/auth.conf validateSchemaVersion=false --write-replication workingDirectory=/store/planet/replication/minute
 2 * * * * planet /home/bretth/bin/osmosis -q --merge-replication-files workingDirectory=/var/lib/replication/hour
 5 * * * * planet /home/bretth/bin/osmosis -q --merge-replication-files workingDirectory=/var/lib/replication/day
-
-MAILTO=zerebubuth@gmail.com
-
-0 7 * * * planet /usr/local/bin/users-agreed
-* * * * * planet /usr/local/bin/replicate-changesets /etc/replication/changesets.conf