Faidon Liambotis has uploaded a new change for review.

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

Change subject: hhvm: use random tmpdir in hhvm-collect-heaps
......................................................................

hhvm: use random tmpdir in hhvm-collect-heaps

Using a static /tmp/heaps isn't a huge deal but not a great idea either.

Change-Id: I7a0f37b09cc84b9d7fe94acd4fe14e544b0ed1ee
---
M modules/hhvm/files/debug/hhvm-collect-heaps
1 file changed, 6 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/29/263829/1

diff --git a/modules/hhvm/files/debug/hhvm-collect-heaps 
b/modules/hhvm/files/debug/hhvm-collect-heaps
index 501f7fe..8bd18c0 100755
--- a/modules/hhvm/files/debug/hhvm-collect-heaps
+++ b/modules/hhvm/files/debug/hhvm-collect-heaps
@@ -1,6 +1,6 @@
 #!/bin/bash
 # Request a heap profile from HHVM once every ten minutes.
-# Profiles are written to /tmp/heaps.
+# Profiles are written to /tmp/hhvm-heaps.XXXXX.
 # Author: Ori Livneh
 
 HHVM_ADMIN_SERVER="${HHVM_ADMIN_SERVER:-http://localhost:9002}";
@@ -18,12 +18,10 @@
   exit 1
 }
 
-echo "Ensuring that /tmp/heaps is writable by ${HHVM_USER}..."
-/bin/mkdir -m0777 -p /tmp/heaps
-/usr/bin/sudo -u "$HHVM_USER" /bin/sh -c 'test -w /tmp/heaps' >/dev/null 2>&1 
|| {
-  echo >&2 "Error: /tmp/heaps is not writable by ${HHVM_USER}."
-  exit 1
-}
+HEAPDIR=$(/bin/mktemp --directory /tmp/hhvm-heaps.XXXXX)
+/bin/chmod 0755 $HEAPDIR
+/bin/chown $HHVM_USER $HEAPDIR
+echo "Using $HEAPDIR for output..."
 
 echo "Enabling heap dumps..."
 { hhvm-admin jemalloc-prof-activate | /bin/grep -q OK && hhvm-admin 
jemalloc-prof-status | /bin/grep -q ACTIVE; } || {
@@ -33,7 +31,7 @@
 
 echo "Entering main loop..."
 for (( i=1; i <= 24; i++ )); do
-    DUMP_FILE="/tmp/heaps/${i}.heap"
+    DUMP_FILE="$HEAPDIR/${i}.heap"
     echo -n "Writing ${DUMP_FILE}..."
     hhvm-admin "jemalloc-prof-dump?file=${DUMP_FILE}"
     echo "Sleeping for ${DUMP_INTERVAL_SECONDS} seconds..."

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a0f37b09cc84b9d7fe94acd4fe14e544b0ed1ee
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to