Ema has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/311119

Change subject: varnish: add varnish-be restart script
......................................................................

varnish: add varnish-be restart script

varnish-backend-restart is a script to depool, restart and repool a
varnish backend.

Change-Id: I9c29d57c46a982af165417125acb10a9768accef
---
A modules/varnish/files/varnish-backend-restart
M modules/varnish/manifests/common/vcl.pp
2 files changed, 38 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/19/311119/1

diff --git a/modules/varnish/files/varnish-backend-restart 
b/modules/varnish/files/varnish-backend-restart
new file mode 100644
index 0000000..c3bf9e0
--- /dev/null
+++ b/modules/varnish/files/varnish-backend-restart
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+set -e
+
+# Depool varnish-be and varnish-be-rand
+confctl --quiet select name=`hostname -f`,service='varnish-be' set/pooled=no
+confctl --quiet select name=`hostname -f`,service='varnish-be-rand' 
set/pooled=no
+
+# Wait a bit for the services to be drained
+sleep 15
+
+# Restart varnish and wipe storage
+service varnish stop
+rm -f /srv/sd*/varnish*
+service varnish start
+
+sleep 5
+
+# Fix VSM files permissions and restart ganglia
+chmod 644 /var/lib/varnish/*/*.vsm
+service ganglia-monitor restart
+
+sleep 5
+
+# Sometimes varnishkafka crashes after a varnish restart
+service varnishkafka-webrequest restart
+
+# Repool varnish-be and varnish-be-rand
+confctl --quiet select name=`hostname -f`,service='varnish-be' set/pooled=yes
+confctl --quiet select name=`hostname -f`,service='varnish-be-rand' 
set/pooled=yes
diff --git a/modules/varnish/manifests/common/vcl.pp 
b/modules/varnish/manifests/common/vcl.pp
index bb61a9d0..0f99637 100644
--- a/modules/varnish/manifests/common/vcl.pp
+++ b/modules/varnish/manifests/common/vcl.pp
@@ -24,6 +24,14 @@
         source => 'puppet:///modules/varnish/errorpage.html',
     }
 
+    # Script to depool, restart and repool a varnish backend
+    file { '/usr/local/sbin/varnish-backend-restart':
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0555',
+        source => 'puppet:///modules/varnish/varnish-backend-restart',
+    }
+
     # VCL unit tests
     file { '/usr/local/sbin/varnish-test-geoip':
         owner  => 'root',

-- 
To view, visit https://gerrit.wikimedia.org/r/311119
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9c29d57c46a982af165417125acb10a9768accef
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ema <e...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to