简体   繁体   中英

Rails application deployment using chef cookbook

I am trying to deploy rails application using chef cookbooks, git .

Here is the example of the code I use to clone private repo from the github.

git "/var/www/hello_app" do
  repository "git://github.com/MyUser/MyProject.git"
  reference "master"
  action "sync"
  user "gituser"
end

My concern is how do I run bundle update/bundle install and rake precompile.

Also start the unicorn web server, I checked deploy resource of the chef docs also.

I am exploring the other ways to get it done,

kindly help me out

My best get would be to use notifications, but its not rock solid (as any failure would involve modifying the app dir so the git resource get updated at next run).

something like :

execute "bundle_install" do
 cwd "/var/www/hello_app"
 command "bundle install"
 action :nothing #To avoid executing at each run
end

git [....] do 
 [...]
 notifies :run,"execute[bundle_install]", :immediately
end

each execute can notifies in turn another one and the last can notify a service to restart for exemple.

You may have a better chance with application cookbook and application_ruby (see the README in the link).

Thoose cookbooks have pre and post deploy hooks and a restart command hook too, they are (IIRC) resilisient to steps failures and may retry on next run if one failed.

I'd go with the deploy resource or the application cookbook. In either case, the bundle install goes into your hooks. I believe the deploy resource actually has an attribute for precompile_command .

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