有许多构建自动化/持续部署工具可以帮助您找到自动化部署管道的解决方案。一些比较流行的配置自动化工具有 puppet、chef、ansible 和 saltstack。我只有 ansible 和 chef 的经验,但我的解释是 chef 是更“用户友好”的选项。我将从那里开始......(厨师使用 ruby 语言,ansible 使用 python)。
我可以回答有关此的具体问题,但小时原始问题确实是开放式和广泛的。
免费教程:https://learn.chef.io/
编辑:我不建议使用 bash 脚本来配置您的服务器/部署......这通常是混乱的,并且随着您的自动化增长(它可能会),您的代码将逐渐变得难以管理。使用诸如 chef 之类的东西,您可以为存储库中的新代码设置定期检查,并在检测到新代码时(或满足某些条件)进行部署。您可以在 ruby 块中编写 strait bash 代码,该代码将远程停止/启动这样的服务(示例):
bash 'Copying the conf file' do
cwd "current/working/directory"
user 'user_name'
code <<-EOH
nohup ./startservice.sh &
sleep 2m
nohup ./startservice.sh &
sleep 3m
EOH
end
例如从 git 复制代码...我在此示例中假设为 github,因为我不知道您的代码所在的位置:
git "/opt/mysources/couch" do
repository "git://git.apache.org/couchdb.git"
reference "master"
action :sync
ssh_wrapper "/some/path/git_wrapper.sh"
end
假设您的代码在其他任何地方..例如竹子或詹金斯...有一个 ruby/chef 资源用于它或使用 strait ruby 代码调用它的某种方式。
这是“您”和您的团队必须为之制定策略的事情。
您可以像这样使用 tar 资源解压文件:
tar_package 'http://pgfoundry.org/frs/download.php/1446/pgpool-3.4.1.tar.gz' do
prefix '/usr/local'
creates '/usr/local/bin/pgpool'
end
或者使用通用的linux命令来喜欢这样:
execute 'extract_some_tar' do
command 'tar xzvf somefile.tar.gz'
cwd '/directory/of/tar/here'
not_if { File.exists?("/file/contained/in/tar/here") }
end
您可以按照我编写第一段代码的方式启动服务器(假设它们是服务。如果您需要重新启动实际的服务器,那么您可以运行init 6 或其他方式。
这只是这些实用程序提供的灵活性的一个示例