From 549950b28190c20d33aabb35edfa09f1f17966a2 Mon Sep 17 00:00:00 2001
From: Todd Dembrey <todd.dembrey@torchbox.com>
Date: Mon, 8 Jan 2018 12:40:44 +0000
Subject: [PATCH] Only run ats-cache-purge on production

---
 fabfile.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/fabfile.py b/fabfile.py
index 6ebd2549f..27a241d6f 100644
--- a/fabfile.py
+++ b/fabfile.py
@@ -140,12 +140,13 @@ def _run_migrate():
 
 @runs_once
 def _post_deploy():
-    # clear frontend cache
-    run(
-        'for host in $(echo $CFG_HOSTNAMES | tr \',\' \' \'); do echo "Purge cache for $host";'
-        'ats-cache-purge $host; '
-        'done'
-    )
+    # clear frontend cache only on production
+    if 'production' in env.effective_roles:
+        run(
+            'for host in $(echo $CFG_HOSTNAMES | tr \',\' \' \'); do echo "Purge cache for $host";'
+            'ats-cache-purge $host; '
+            'done'
+        )
 
     # update search index
     run('django-admin update_index')
-- 
GitLab