I've got a task that can be run from the command line with a task_to_run parameter specified:
task :run_on_app, :roles => :app do
run <<-CMD
cd #{current_path} &&
rake #{task_to_run} RAILS_ENV=#{rails_env}
CMD
end
That runs just fine.
However, I have another task (within my deploy.rb file) that I would also like to run this task. How do I format the command so that it essentially passes the equivalent of the "-s task_to_run=" to it?
I tried:
task :clear_sessions, { :roles => :app, :only => { :primary => true }} do
rake_tasks.run_on_primary_app task_to_run="db:sessions:clear"
end
and
task :clear_sessions, { :roles => :app, :only => { :primary => true }} do
task_to_run = "db:sessions:clear"
rake_tasks.run_on_primary_app(task_to_run)
end
What am I doing wrong?