Skip to content

Instantly share code, notes, and snippets.

@gordonbisnor
Created August 20, 2009 19:56
Show Gist options
  • Save gordonbisnor/171309 to your computer and use it in GitHub Desktop.
Save gordonbisnor/171309 to your computer and use it in GitHub Desktop.
Rails Cap Deploy For WebFaction
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
user = 'me'
password = "my_password"
application = 'me'
domain = 'me.com'
set :webfaction_port, "my port number goes here"
set :webfaction_username, "#{user}"
set :user, user
set :domain, domain
set :application, application
set :repository, "#{user}@#{domain}:/home/#{user}/git/#{application}"
set :scm, :git
set :rake, "/home/#{user}/ruby1.8/lib/ruby/gems/1.8/bin/rake"
set :deploy_via, :checkout
set :scm_command, "/home/#{user}/git-1.6.5.6/git"
set :local_scm_command, "git"
set :scm_username, user
set :scm_password, "#{password}"
set :scm_passphrase, "#{password}"
set :use_sudo, false
set :branch, "master"
set :scm_verbose, true
set :git_shallow_clone, 1
set :deploy_to, "/home/#{user}/webapps-releases/#{application}"
set :group_writable, false
set :keep_releases, 4
role :app, domain
role :web, domain
role :db, domain, :primary => true
desc "Symlink public to what webfaction expects the webroot to be"
task :after_symlink, :roles => :web do
run "ln -nfs #{release_path}/public /home/#{webfaction_username}/webapps/#{application}/"
end
namespace :deploy do
desc "Redefine deploy:start"
task :start, :roles => :app do
invoke_command "/home/#{user}/ruby1.8/lib/ruby/gems/1.8/bin/mongrel_rails start -c #{deploy_to}/current -d -e production -P /home/#{webfaction_username}/webapps/#{application}/log/mongrel.pid -p #{webfaction_port}", :via => run_method
end
desc "Redefine deploy:restart"
task :restart, :roles => :app do
invoke_command "/home/#{user}/ruby1.8/lib/ruby/gems/1.8/bin/mongrel_rails restart -c #{deploy_to}/current -P /home/#{webfaction_username}/webapps/#{application}/log/mongrel.pid", :via => run_method
end
desc "Redefine deploy:stop"
task :stop, :roles => :app do
invoke_command "/home/#{user}/ruby1.8/lib/ruby/gems/1.8/bin/mongrel_rails stop -c #{deploy_to}/current -P /home/#{webfaction_username}/webapps/#{application}/log/mongrel.pid", :via => run_method
end
end
after "deploy:update", "deploy:cleanup" # OTHER WISE OLD RELEASES WILL NOT BE DELETED EVEN THOUGH KEEP IS SET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment