Boost Core Auto Deploy Process

From Metro Studios Knowledgebase

Jump to: navigation, search

In order to assure that all new core updates are pushed/added to every site, we've set up an auto deploy process that will step through all sites on all of our servers (with the exception of slice4) and traverse into each sites boost core repository and pull from the master (dev1.metro-studios.com/var/www/git/boost/core.git).

Once a commit is pushed to the master repo, a post update hook (dev1.metro-studios.com/var/www/git/boost/core.git/hooks/post-update) is fired off which runs the following commands:

cd /home/coreupdate/;
sudo -u coreupdate  bash core_update.sh &> core_update.log;
sudo -u coreupdate  bash mail_core_update_log.sh;
 
sudo -u coreupdate  bash b2_core_update.sh &> b2_core_update.log;
sudo -u coreupdate  bash b2_mail_core_update_log.sh;

We'll break each piece down to clearly define its role in the whole process.

  1. cd /home/coreupdate/;

    This command changes the directory to the coreupdate user (the user that has permissions to run all the scripts on all the individual servers).

  2. sudo -u coreupdate  bash core_update.sh &> core_update.log;

    This command runs the script /home/coreupdate/core_update.sh which steps through each server and runs the [SERVER]/home/coreupdate/update_site_cores.sh as the user coreupdate and logs the output from the script into the file /home/coreupdate/core_update.log.

  3. sudo -u coreupdate  bash mail_core_update_log.sh;

    This command runs the script /home/coreupdate/mail_core_update_log.sh as the user coreupdate which mails the contents of the core_update.log file to [email protected]


[edit] Process Summary

Once the commit has been pushed to the master repo, the core_update script steps through each of our servers and runs the update_site_cores script on that server. The update_site_cores script will step through each virtual host in the /var/www/vhosts/ directory and check to see if the _boost directory exists. If the site has boost installed, the script will traverse into the core and run a git pull from the origin which will update that repo, before moving on to the next virtual host. Once all servers have been updated, the script will then load the log file that was generated and will email that out to [email protected] (the email account set up to send to all of our developers).


[edit] Referenced Scripts

  1. dev1.metro-studios.com/home/coreupdate/core_update.sh
    web_servers=(web3 web4 web5 web6 dev1)
    # Loop through all servers and run the update_site_cores.sh shell script
    for server in ${web_servers[@]}; do
         echo $server;
         ssh -p 11200 -t -t coreupdate@${server}.metro-studios.com '~/update_site_cores.sh';
    done
     
    2>&1 | tee logfile.log
  2. [SERVER]/home/coreupdate/update_site_cores.sh
    DIRS=$(find "/var/www/vhosts/" -maxdepth 1 -type d)
     
    for dir in $DIRS
    do
            if [ -d "${dir}/httpdocs/_boost" ]; then
                    echo "${dir} is being updated."
                    cd ${dir}/httpdocs/_boost/core/;
                    git pull origin master;
                    sudo chown -R coreupdate:git-users ${dir}/httpdocs/_boost/core/;
                    sudo chown -h coreupdate:git-users ${dir}/httpdocs/_admin;
            fi
    done
Personal tools
Namespaces
Variants
Actions
Wiki Navigation
Knowledgebase
Toolbox