简体   繁体   English

厨师application_ruby食谱:独角兽未重启

[英]chef application_ruby cookbook: unicorn is not restarted

I have the following application defined using application and application_ruby cookbooks: 我使用application和application_ruby食谱定义了以下应用程序:

application 'railsapp' do
  owner 'vagrant'
  group 'vagrant'
  path '/home/vagrant/railsapp'
  revision 'master'
  repository 'git@github.com:rohshall/railsreadings.git'
  migrate true
  rails do
    bundler true
    database do
      host 'localhost'
      username mysql_connection_info[:username]
      password mysql_connection_info[:password]
      database 'railsreadings_production'
      adapter 'mysql2'
      encoding 'utf8'
    end
  end
  unicorn do
    preload_app true
    port "9000"
    worker_timeout 30
    worker_processes 2
  end
end

Even though I have preload_app true, unicorn is not restarted. 即使我的preload_app为true,麒麟也不会重新启动。 I can see from the chef log that unicorn's before_compile cook and before_deploy hooks are executed, but it does not go into before_restart. 我从厨师日志中可以看到,执行了独角兽的before_compile cook和before_deploy挂钩,但是它没有加入before_restart中。 Any pointers about my mistakes in configuration? 关于我的配置错误的任何指示?

The model with the application cookbook is that it will look for a "restart_command" in each of the registered resources and trigger these between the before_restart and after_restart callbacks. 应用程序食谱的模型是,它将在每个已注册资源中寻找“​​ restart_command”,并在before_restart和after_restart回调之间触发这些资源。 In the previous releases of the application_ruby this would default to "touch tmp/restart.txt" which is the default for passenger. 在application_ruby的先前版本中,此默认设置为“ touch tmp / restart.txt”,这是乘客的默认设置。 In the current release there is no default restart_command. 在当前版本中,没有默认的restart_command。

I suggest adding a suitable command for unicorn: 我建议为独角兽添加合适的命令:

application 'railsapp' do
  ...
  restart_command "service unicorn restart"
  ...
end

Depending on the version of the application_ruby cookbook, you may need to put this under the "rails" resource. 根据application_ruby cookbook的版本,您可能需要将其放在“ rails”资源下。

We use these cookbooks extensively at Ninefold in our rails app deployment service and generally they work very well. 我们在Rails应用程序部署服务中的Ninefold上广泛使用了这些食谱,并且它们通常都工作得很好。 We find the actual callbacks very useful to over-ride the inbuilt actions such as migrations and asset precompilation to provide better control and reporting. 我们发现实际的回调对于覆盖诸如迁移和资产预编译之类的内置操作非常有用,以提供更好的控制和报告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM