简体   繁体   中英

chef application_ruby cookbook: unicorn is not restarted

I have the following application defined using application and application_ruby cookbooks:

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. 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. 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. In the previous releases of the application_ruby this would default to "touch tmp/restart.txt" which is the default for passenger. In the current release there is no default 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.

We use these cookbooks extensively at Ninefold in our rails app deployment service and generally they work very well. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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