Chef和git sync - 如何在给定更新的情况下通知runit服务重新加载?

时间:2012-04-03 10:35:41

标签: chef

我正在使用以下内容在我的厨师食谱中同步我的github回购。

branch_name = "master"
git "/home/ubuntu/workspace/repo" do                            
    repository "git@github.com:me/repo.git"
    revision branch_name                                  
    action :sync                                     
    user "root"                                                                  
end

在repo中是运行我的spawn-fcgi应用程序的python web.py脚本。我正在使用runit配方来运行我的spawn-fcgi作业。

include_recipe "runit"
runit_service "myservice"

问题是...已经在repo中更新了index.py脚本...如何通知runit scipt myservice重新加载我的spawn-fcgi脚本?

1 个答案:

答案 0 :(得分:7)

如果我理解正确,这应该在git更新后重新加载服务:

branch_name = "master"
git "/home/ubuntu/workspace/repo" do                            
    repository "git@github.com:me/repo.git"
    revision branch_name                                  
    action :sync                                     
    user "root"                                                                  
    notifies :restart, "service[myservice]"
end

重新加载将推迟到厨师运行结束。要立即实现,您可以将最后一行更改为:

notifies :restart, "service[myservice]", :immediately

runit_service定义不支持:重新加载为操作。请注意,这将在git版本更改时重新启动服务(因此更新了本地存储库)。如果您只想监视单个文件,则可能需要编写脚本或其他内容来检查更新的文件,但我怀疑任何git更改都应该重新启动。