Last active
March 9, 2019 15:36
-
-
Save kasunbg/444df28a2e51a16bbd74 to your computer and use it in GitHub Desktop.
wso2 carbon DepSync via rsync
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/sh | |
#A snippet to synchronize the CARBON_HOME/repository/deployment/server folders between manager and all worker nodes. | |
#Add a file called workers-list.txt that has a syntax like follows separated by new lines. | |
#[email protected]:~/setup/192.168.1.1/as/as_worker/repository/deployment/server | |
manager_server_dir=~/wso2as-5.2.1/repository/deployment/server | |
pem_file=~/.ssh/carbon-440-test.pem | |
#delete the lock on exit | |
trap 'rm -rf /var/lock/depsync-lock' EXIT | |
mkdir /tmp/carbon-rsync-logs/ | |
#keep a lock to stop parallel runs | |
if mkdir /var/lock/depsync-lock; then | |
echo "Locking succeeded" >&2 | |
else | |
echo "Lock failed - exit" >&2 | |
exit 1 | |
fi | |
#get the workers-list.txt | |
pushd `dirname $0` > /dev/null | |
SCRIPTPATH=`pwd` | |
popd > /dev/null | |
echo $SCRIPTPATH | |
for x in `cat ${SCRIPTPATH}/workers-list.txt` | |
do | |
echo ================================================== >> /tmp/carbon-rsync-logs/logs.txt; | |
echo Syncing $x; | |
rsync --delete -arve "ssh -i $pem_file -o StrictHostKeyChecking=no" $manager_server_dir $x >> /tmp/carbon-rsync-logs/logs.txt | |
echo ================================================== >> /tmp/carbon-rsync-logs/logs.txt; | |
done |
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
#The cronjob to run the above script every minute. | |
#You can add this cronjob by running the command `crontab -e`. | |
#Verify the cron config by running `crontab -l` | |
* * * * * /home/ubuntu/setup/rsync-for-depsync/rsync-for-depsync.sh |
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
[email protected]:~/setup/192.168.1.1/as/as_worker/repository/deployment/server | |
[email protected]:~/setup/192.168.1.2/as/as_worker/repository/deployment/server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment