diff --git a/CHANGELOG b/CHANGELOG index a371ebb3..5e211044 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ *SVN* +* Add :restart_via variable for specifying whether restart ought to use :sudo (default, use sudo) + +* Use SFTP for file transfers (if available). + * Add an "update_current" task that will do an svn up on the current release * Use the :checkout variable to determine what operation to use for svn checkouts (instead of co, like "export"). diff --git a/lib/switchtower/actor.rb b/lib/switchtower/actor.rb index d58fb577..d33c3905 100644 --- a/lib/switchtower/actor.rb +++ b/lib/switchtower/actor.rb @@ -66,6 +66,7 @@ module SwitchTower def initialize(name, options) @name, @options = name, options + @servers = nil end # Returns the list of servers (_not_ connections to servers) that are @@ -110,7 +111,7 @@ module SwitchTower logger.trace "executing task #{name}" begin push_task_call_frame name - result = instance_eval &block + result = instance_eval(&block) ensure pop_task_call_frame end diff --git a/lib/switchtower/recipes/standard.rb b/lib/switchtower/recipes/standard.rb index 08eb560a..6091e85e 100644 --- a/lib/switchtower/recipes/standard.rb +++ b/lib/switchtower/recipes/standard.rb @@ -4,12 +4,18 @@ # application servers. # * The :web role has been defined as the set of machines consisting of the # web servers. -# * The Rails spinner and reaper scripts are being used to manage the FCGI +# * The :db role has been defined as the set of machines consisting of the +# databases, with exactly one set up as the :primary DB server. +# * The Rails spawner and reaper scripts are being used to manage the FCGI # processes. -# * There is a script in script/ called "reap" that restarts the FCGI processes set :rake, "rake" +set :migrate_target, :current +set :migrate_env, "" + +set :restart_via, :sudo + desc "Enumerate and describe every available task." task :show_tasks do keys = tasks.keys.sort_by { |a| a.to_s } @@ -91,14 +97,15 @@ task :symlink, :roles => [:app, :db, :web] do run "ln -nfs #{current_release} #{current_path}" end -desc "Restart the FCGI processes on the app server." +desc <<-DESC +Restart the FCGI processes on the app server. This uses the :restart_via +variable to determine whether to use sudo or not. By default, :restart_via is +set to :sudo, but you can set it to :run if you are in a shared environment. +DESC task :restart, :roles => :app do - sudo "#{current_path}/script/process/reaper" + send(restart_via, "#{current_path}/script/process/reaper") end -set :migrate_target, :current -set :migrate_env, "" - desc <<-DESC Run the migrate rake task. By default, it runs this in the version of the app indicated by the 'current' symlink. (This means you should not invoke this task