Last active
January 14, 2018 14:28
-
-
Save nemke82/2f01e53470fa71065d37941dadf07209 to your computer and use it in GitHub Desktop.
Script to speed up Magento 2 indexer execution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Author: Nemanja Djuric | |
#Script to speed up Magento 2 indexer execution. NOTE: Ajust PHP name, if necessarry. | |
if [[ -e app/etc/env.php ]]; then | |
echo "Getting the list of indexers for this Magento installation." | |
indexlist=$(php bin/magento indexer:info | awk {'print $1'}) | |
echo ${indexlist} | |
echo "Getting the number of indexers for this Magento installation." | |
indexcount=$(php bin/magento indexer:info | awk {'print $1'} | wc -l) | |
echo ${indexcount} | |
echo "Invalidating indexers, preparing for fresh start." | |
indexreset=$(php bin/magento indexer:reset) | |
echo ${indexreset} | |
for i in $(seq $indexcount); do | |
#magic starts here... | |
indexer_used=$(php bin/magento indexer:info | awk {'print $1'} | sed -n "$i"p) | |
echo "$(whereis n98-magerun2 | awk -F ":" '{print $2'}) indexer:reindex $indexer_used && rm -f $(pwd -P)/count$i.sh" > $(pwd -P)/count$i.sh ; | |
chmod a+rwx $(pwd -P)/count$i.sh; | |
screen -d -m -S count$i $(pwd -P)/count$i.sh ; done | |
else | |
echo "please cd into installation directory" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment