colinmollenhour / modman

Modularize extensions using symlinks. Voted #1 Magento tool by @WebShopApps!
728 stars 177 forks source link

How to use modman on multi-server deployments? #66

Open horninc opened 10 years ago

horninc commented 10 years ago

I am using AWS Elastic Beanstalk. This, and almost all other, multi server deployment requires all of the code to be in a .git repo, that can be updated, and then deployed all servers in the cluster at once.

My problem is that modman creates .git folders under .modman/extension_name folder, so all of this source code is automatically omitted when committing, and pushing changes.

I can, of course, manually connect to EC2 or similar instances and run modman commands from there, but it defies logic, as it disrupts the whole automatic scaling concept that large scale magento shops require.

Please advise.

brb3 commented 10 years ago

The way we handle this is we setup all of our remote servers with a .modman/whatever folder, and initialize it as a git repo. We then add a post-receive git-hook that looks like this:

#!/bin/bash
RESTORE='\033[0m'
BOLD='\033[1m'
BLUE='\033[00;34m'
MSGBEGIN="${BOLD}${BLUE}::${RESTORE}${BOLD}"
read oldrev newrev refname
oldIFS=${IFS}
IFS='/' read -a parts <<< "$refname"
IFS=${oldIFS}
echo -e "${MSGBEGIN} Checking out branch '${parts[2]}'. ${RESTORE}"
git checkout -f ${parts[2]}
git reset --hard

echo -e "${MSGBEGIN} Redeploying modman. ${RESTORE}"
modman deploy

# Any other application specific stuff I need to do

echo -e "${MSGBEGIN} Done. ${RESTORE}"

Then I have a helper script that does a git push to all my remote servers at the same time.

We are not using EC2, however, and I'm not sure if this would translate directly, but hopefully this will help get you started.

horninc commented 10 years ago

Issue that we are having with Elastic Beanstalk is that it does not have post deployment hooks! I will try your version (I assume its derived from OpsWorks) to get started and on the right track, but it would be amazing if you could spare some minutes to give more details on why you take these steps in your code.

The first question I get about your setup is - why do you deploy, and why does it differ from checkout?

Its not clear to me how it actually works :( and if the modman in your case is still the part of other .git repository.