Created
January 5, 2011 18:06
-
-
Save Atalanta/766703 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app = node.run_state[:current_app] | |
| use_ree = false | |
| if node.run_state[:seen_recipes].has_key?("ruby_enterprise") | |
| use_ree = true | |
| end | |
| if app['packages'] | |
| app['packages'].each do |pkg,ver| | |
| package pkg do | |
| action :install | |
| version ver if ver && ver.length > 0 | |
| end | |
| end | |
| end | |
| # Set up capistrano-like deploy infrastructure | |
| directory app['deploy_to'] do | |
| owner app['owner'] | |
| group app['group'] | |
| mode '0755' | |
| recursive true | |
| end | |
| directory "#{app['deploy_to']}/shared" do | |
| owner app['owner'] | |
| group app['group'] | |
| mode '0755' | |
| recursive true | |
| end | |
| %w{ log pids system config dbbackups published_pages uploaded_local_media }.each do |dir| | |
| directory "#{app['deploy_to']}/shared/#{dir}" do | |
| owner app['owner'] | |
| group app['group'] | |
| mode '0755' | |
| recursive true | |
| end | |
| end | |
| execute "Set up virtual environment" do | |
| cwd "#{app['deploy_to']}" | |
| command "virtualenv --no-site-packages virtualenv" | |
| creates "#{app['deploy_to']}/virtualenv" | |
| end | |
| if app.has_key?("deploy_key") | |
| ruby_block "write_key" do | |
| block do | |
| f = File.open("#{app['deploy_to']}/id_deploy", "w") | |
| f.print(app["deploy_key"]) | |
| f.close | |
| end | |
| not_if do File.exists?("#{app['deploy_to']}/id_deploy"); end | |
| end | |
| file "#{app['deploy_to']}/id_deploy" do | |
| owner app['owner'] | |
| group app['group'] | |
| mode '0600' | |
| end | |
| template "#{app['deploy_to']}/deploy-ssh-wrapper" do | |
| source "deploy-ssh-wrapper.erb" | |
| owner app['owner'] | |
| group app['group'] | |
| mode "0755" | |
| variables app.to_hash | |
| end | |
| end | |
| deploy_revision app['id'] do | |
| revision app['revision'][node.app_environment] | |
| repository app['repository'] | |
| user app['owner'] | |
| group app['group'] | |
| deploy_to app['deploy_to'] | |
| ssh_wrapper "#{app['deploy_to']}/deploy-ssh-wrapper" if app['deploy_key'] | |
| before_migrate do | |
| @current_release = release_path | |
| bash "Synchronise DB" do | |
| cwd #{@current_release} | |
| code <<-EOH | |
| source #{app['deploy_to']}/virtualenv/bin/activate | |
| python #{id}/manage.py syncdb | |
| EOH | |
| end | |
| end | |
| # if app['migrate'][node.app_environment] && node[:apps][app['id']][node.app_environment][:run_migrations] | |
| # migrate true | |
| # migration_command app['migration_command'] | |
| # else | |
| # migrate false | |
| # end | |
| end | |
| execute "Install pip requirements" do | |
| cwd @current_release | |
| command "pip install -r live-pip-requirements.txt" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment