Skip to content

Commit

Permalink
add deploy:app:start, deploy:app:stop, and deploy:cold, and correspon…
Browse files Browse the repository at this point in the history
…ding compat tasks

git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@6492 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jamis committed Mar 29, 2007
1 parent 523021d commit bacdd7e
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 10 deletions.
27 changes: 18 additions & 9 deletions lib/capistrano/recipes/compat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
# Depends on the deployment system
load 'deploy'

map = { "diff_from_last_deploy" => "deploy:pending:diff",
"update" => "deploy:update",
"update_code" => "deploy:update_code",
"symlink" => "deploy:symlink",
"restart" => "deploy:restart",
"rollback" => "deploy:rollback",
"cleanup" => "deploy:cleanup",
"disable_web" => "deploy:web:disable",
"enable_web" => "deploy:web:enable" }
map = { "diff_from_last_deploy" => "deploy:pending:diff",
"update" => "deploy:update",
"update_code" => "deploy:update_code",
"symlink" => "deploy:symlink",
"restart" => "deploy:restart",
"rollback" => "deploy:rollback",
"cleanup" => "deploy:cleanup",
"disable_web" => "deploy:web:disable",
"enable_web" => "deploy:web:enable",
"cold_deploy" => "deploy:cold",
"deploy_with_migrations" => "deploy:migrations" }

map.each do |old, new|
desc "DEPRECATED: See #{new}."
Expand All @@ -21,3 +23,10 @@
find_and_execute_task(#{new.inspect})
end"
end

desc "DEPRECATED: See deploy:app:start."
task :spinner do
warn "[DEPRECATED] `spinner' is deprecated. Use `deploy:app:start' instead."
set :runner, fetch(:spinner_user, "app")
deploy.app.start
end
46 changes: 45 additions & 1 deletion lib/capistrano/recipes/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
task) prior to updating the symlink. Note that the update in this case it is \
not atomic, and transactions are not used, because migrations are not \
guaranteed to be reversible."
task :with_migrations do
task :migrations do
set :migrate_target, :latest
update_code
migrate
Expand Down Expand Up @@ -273,6 +273,50 @@
end
end

desc "Deploys and starts a `cold' application. This is useful if you have not \
deployed your application before, or if your application is (for some other \
reason) not currently running. It will deploy the code, and then instead of \
invoking `deploy:restart', it will invoke `deploy:app:start' to fire up the \
application servers."
task :cold do
update
app.start
end

namespace :app do
desc "Start the application servers. This will attempt to invoke a script \
in your application called `script/spin', which must know how to start your \
application listeners. For Rails applications, you might just have that script \
invoke `script/process/spawner' with the appropriate arguments.
By default, the script will be executed via sudo as the `app' user. If you \
wish to run it as a different user, set the :runner variable to that user. \
If you are in an environment where you can't use sudo, set the :use_sudo \
variable to false."
task :start, :roles => :app do
as = fetch(:runner, "app")
via = fetch(:run_method, :sudo)
invoke_command "sh -c 'cd #{current_path} && nohup script/spin'", :via => via, :as => as
end

desc "Stop the application servers. This will call script/process/reaper for \
both the spawner process, and all of the application processes it has spawned. \
As such, it is fairly Rails specific and may need to be overridden for other \
systems.
By default, the script will be executed via sudo as the `app' user. If you \
wish to run it as a different user, set the :runner variable to that user. \
If you are in an environment where you can't use sudo, set the :use_sudo \
variable to false."
task :stop, :roles => :app do
as = fetch(:runner, "app")
via = fetch(:run_method, :sudo)

invoke_command "#{current_path}/script/process/reaper -a kill -r dispatch.spawner.pid", :via => via, :as => as
invoke_command "#{current_path}/script/process/reaper -a kill", :via => via, :as => as
end
end

namespace :pending do
desc "Displays the `diff' since your last deploy. This is useful if you want \
to examine what changes are about to be deployed. Note that this might not be \
Expand Down

0 comments on commit bacdd7e

Please sign in to comment.