Skip to content

Instantly share code, notes, and snippets.

@fprochazka
Last active October 27, 2018 16:15
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fprochazka/4c92cd5d0a1f100d2f0d to your computer and use it in GitHub Desktop.
Save fprochazka/4c92cd5d0a1f100d2f0d to your computer and use it in GitHub Desktop.
.git/hooks/post-checkout

post checkout hook na mazání cache

  • post-checkout.sh uložit jako .git/hooks/post-checkout
  • .invalidate-opcache.php jako www/.invalidate-opcache.php (POZOR! - tenhle soubor buďto na produkci nenahrávat, nebo zablokovat přístup!)
<?php
if (function_exists("opcache_reset")) {
opcache_reset();
}
if (function_exists("apc_clear_cache")) {
apc_clear_cache();
apc_clear_cache("user");
}
echo "Opcache invalidated\n";
#!/bin/sh
oldrev="$1"
newrev="$2"
# --- Safety check
if [ -z "$GIT_DIR" ]; then
echo "Don't run this script from the command line." >&2
echo " (if you want, you could supply GIT_DIR then run" >&2
echo " $0<oldrev> <newrev>)" >&2
exit 1
fi
echo "[Cache]: flushing redis db 2 ... $(redis-cli -n 2 flushdb)"
echo "[Cache]: cleaning filesystem cache ..."
/bin/rm -R $(pwd)/temp/cache/*/ 2> /dev/null
/bin/rm -R $(pwd)/tests/tmp/*/ 2> /dev/null
echo "[Cache]: http... $(curl --silent http://rohlik.l/.invalidate-opcache.php)"
echo "[Cache]: cli... $(php $GIT_DIR/../www/.invalidate-opcache.php)"
echo "[Composer]: $(composer --working-dir="$GIT_DIR/.." dump-autoload)"
# /usr/local/bin/php $(pwd)/www/index.php orm:generate:proxies 1> $(pwd)/log/generate-proxies.log &
# --- Finished
exit 0
@fprochazka
Copy link
Author

Ten invalidate-opcache samozřejmě na produkci není veřejně přístupný ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment