这里采用的代码版本控制程序为Subversion,由中央版本库向多台服务器同步代码的方法有很多,基本上都是通过使用hook(post-commit)来实现的.
这里记录下我的post-commit:
use Net::SSH::Expect;
#此处添本代码仓库需要同步的服务器组
my @cluster = ('192.168.1.191',
'192.168.1.190',
'192.168.1.193'
);
foreach $svr (@cluster) {
my $ssh = Net::SSH::Expect->new(
host =$svr,
password ='xxx',
user ='xxx',
raw_pty =1
);
my $logins = $ssh->login();
my $command = $ssh->exec('svn up /path');
$ssh->close();
}
#此处添本代码仓库需要同步的服务器组
my @cluster = ('192.168.1.191',
'192.168.1.190',
'192.168.1.193'
);
foreach $svr (@cluster) {
my $ssh = Net::SSH::Expect->new(
host =$svr,
password ='xxx',
user ='xxx',
raw_pty =1
);
my $logins = $ssh->login();
my $command = $ssh->exec('svn up /path');
$ssh->close();
}
No comments:
Post a Comment