5 INI
="/etc/hhvm/server.ini"
8 echo "Usage: $0 enable root-dir"
11 echo "Enables HHVM's \"repo authoritative\" mode. In this mode, HHVM"
12 echo "uses a pre-built and pre-optimized version of your PHP or Hack"
13 echo "source code. These ahead-of-time optimizations mean that code run"
14 echo "in repo mode can be significantly faster. Keep in mind that after"
15 echo "this mode is enabled, source code is no longer consulted, so"
16 echo "changes there will not be reflected unless this command is re-run"
17 echo "to either rebuild the repo or disable repo authoritative mode."
19 echo "This command changes HHVM configuration; you will probably need"
23 echo "$0 enable root-dir"
25 echo "Enables repo authoritative mode. Finds PHP or Hack source code"
26 echo "under \"root-dir\" and computes an optimized repo where that code"
27 echo "(and only that code) is available. If repo mode is already"
28 echo "enabled, the repo will be recomputed and replaced."
33 echo "Disables repo authoritative mode. HHVM will return to its default"
34 echo "configuration of reading and executing code directly from disk."
39 HHBC
=`grep hhvm.repo.path "$INI" | sed 's/[^=]*=\s*\(.*\)/\1/'`
40 if [ "x$HHBC" = "x" ]; then
41 mkdir
-p /var
/cache
/hhvm
42 USER
=`stat -c "%U" "/var/run/hhvm"`
43 chown
-R "$USER" "/var/cache/hhvm"
44 echo "hhvm.repo.path = /var/cache/hhvm/hhvm.hhbc" >> "$INI"
45 HHBC
="/var/cache/hhvm/hhvm.hhbc"
51 find "$1" -type f
> "$FILE_LIST"
53 OUT_DIR
=`dirname "$HHBC"`
54 hhvm
--hphp --output-dir "$OUT_DIR" --input-list "$FILE_LIST" -l3
56 OUT_DIR_USER
=`stat -c "%U" "$OUT_DIR"`
57 HHBC_USER
=`stat -c "%U" "$HHBC"`
58 if [ "$OUT_DIR_USER" != "$HHBC_USER" ]; then
59 chown
"$OUT_DIR_USER" "$HHBC"
62 echo "hhvm.repo.authoritative = true" >> "$INI"
67 sed -i '/hhvm.repo.authoritative/d' "$INI"
72 if [ "$#" -ne 2 ] ||
! [ -d "$2" ]; then
73 echo "Invalid root-dir"