task :first do
set :var, "value 1"
set..
end
task :second do
set :var, "value 2"
set ..
end
and then calling cap like "cap first deploy" or "cap second deploy".
No need for anything else....
izidor
== config/deploy.rb
set :stages, %w(foo bar)
set :default_stage, "foo"
require 'capistrano/ext/multistage'
set :repository, "https://repository/trunk"
set :user, "my_user"
...
# Some common tasks
== config/deploy/foo.rb
role :app, "foo.host.com"
role :web, "foo.host.com"
role :db, "foo.host.com", :primary => true
== config/deploy/bar.rb
role :app, "bar.host.com", "bar2.host.com"
role :web, "bar.host.com"
role :db, "bar.host.com", :primary => true
In this case. I used differents hosts in differents stages. You can do
the same with tasks.
Regards
me escribió:
--
Rafael Garcia Ortega
and try this task:
cap dev shell
then put:
pwd
It will show you the path in remote server.
Regards!
PS: I think that "run ..." must be in a task.
escribió:
--
Rafael Garcia Ortega
For example:
== config/deploy.rb
# Common variables
# ...
# Tasks for mongrel
desc "Modified restart task for work ONLY with mongrel cluster"
task :restart do
stop
start
end
desc "Modified start task for work ONLY with mongrel cluster"
task :start do
run "cd #{deploy_to}/current && mongrel_rails cluster::start"
end
desc "Modified stop task for work ONLY with mongrel cluster"
task :stop do
run "cd #{deploy_to}/current && mongrel_rails cluster::stop"
end
# Tasks for config files
namespace :config_files do
require 'erb'
desc "Create config files:database.yml, mongrel_cluster.yml and mailer.rb"
task :default do
database_yml
mongrel_cluster_yml
mailer_rb
local_config_rb
end
desc "Make symlink for config files"
task :symlink do
symlink_database_yml
symlink_mongrel_cluster_yml
symlink_mailer_rb
symlink_local_config_rb
end
desc "Create mongrel_cluster yaml in shared path"
task :mongrel_cluster_yml do
template = File.read(File.join(File.dirname(__FILE__), "deploy/templates", "mongrel_cluster.erb"))
result = ERB.new(template).result(binding)
run "mkdir -p #{shared_path}/config"
put result, "#{shared_path}/config/mongrel_cluster.yml"
end
desc "Make symlink for mongrel_cluster yaml"
task :symlink_mongrel_cluster_yml do
run "ln -nfs #{shared_path}/config/mongrel_cluster.yml #{release_path}/config/mongrel_cluster.yml"
end
# More config_files tasks
# ...
# More common tasks
# ...
== config/deploy/templates/mongrel_cluster.erb
---
user: <%= mongrel_username %>
group: <%= mongrel_group %>
cwd: <%= current_path %>
port: "<%= mongrel_port %>"
environment: <%= rails_env || 'production' %>
address: 127.0.0.1
pid_file: <%= shared_path %>/log/mongrel.pid
log_file: <%= shared_path %>/log/mongrel.log
servers: <%= mongrel_servers %>
== config/deploy/stage1.rb
set :user, "foo"
# Mongrel configuration variables
set :mongrel_port, 8008
set :mongrel_servers, 3
set :mongrel_username, user # Change if user is diffent to shell user
set :mongrel_group, user # Change if group is different to shell group
role :app, "foo.com"
role :web, "foo.com"
role :db, "bar.com", :primary => true
# More tasks and variables
#...
== config/deploy/stage2.rb
# Mongrel configuration variables
set :mongrel_port, 3000
set :mongrel_servers, 2
set :mongrel_username, "foobar"
set :mongrel_group, "foobar"
role :app, "baz.com"
role :web, "baz.com"
role :db, "baz.com", :primary => true
# More tasks and variables
#...
More or less :)
Regards
me escribió:
--
Rafael Garcia Ortega
With this tasks only create the files in shared path, remember that I
used a trigger/callback that creates symbolics links after
deploy:update_code. All will run ok before create symlinks in config path.
me escribió:
>
> I commented out databas_yml, mailer_rb, and local_config_rb since I
> wanted to address just my issue with the mongrel cluster pointing to
> the right YAML file at startup. Was this wrong to do, especially
> commenting out database_yml? Does this mean it is unable to find the
> location for database.yml?
>
>
Surely, you will fail because it lacks the configuration files.
Regards
--
Rafael Garcia Ortega