I'm getting this error as well. If I modify the lines that use
#{stage} (so they don't error out) and plug in the task :show_stage,
the correct stage is spit out. It's only when I'm using them in string
eval set(:bar) {"#{stage}"} that they are not coming thru.
# each of the deploy/#{stage}.rb files look something like the
following:
production.rb
set :repos, "tags/current"
set :apache_proxy_port, 8000
set :apache_proxy_servers, 3
---------------------
##############
### Deploy.rb
##############
set :stages, %w(dev staging production)
set :default_stage, 'dev'
##############
### Global Rollout options
##############
set(:domain) {"#{stage}.foobar.com"} # <- this fails SECOND if the
application line is modified (e.g. the deploy file is being parsed
bottom up somehow?)
set :app_name, "foobar"
# Lazily eval since we don't know this til runtime
set(:application) {"#{stage}.#{app_name}"} # this fails, undef var
stage
##############
### SVN Stuff
##############
set :deploy_via, :export
set :user, "deploy"
set :group, user
# The SVN repos is not in a subdomain location, so we need to capture
the "deploy root"
set :deploy_root, "var/www/apps/#{app_name}"
# Target directory for the application on the web and app servers.
set(:deploy_to) {"/#{deploy_root}/#{application}"}
set(:repository) {"svn+ssh://[EMAIL PROTECTED]/#{deploy_root}/repos/
#{repos}"}
##############
### Misc
##############
# This must be after deploy_to
set :mongrel_conf, "#{current_path}/config/mongrel_cluster.yml"
set :rails_env, "production"
#
=============================================================================
# ROLES
#
=============================================================================
role(:web) {domain}
role(:app) {domain}
role :db, domain, :primary => true
#doesn't work -> role(:db) {domain, :primary => true}
role(:scm) {domain}
#
=============================================================================
# APACHE OPTIONS
#
=============================================================================
set :apache_server_name, domain
#set :apache_server_aliases, %w{alias1 alias2}
set :apache_default_vhost, true # force use of
apache_default_vhost_config
set :apache_default_vhost_conf, "/etc/httpd/conf/default.conf"
set :apache_conf, "/etc/httpd/conf/apps/#{app_name}.conf"
set :apache_ctl, "/etc/init.d/httpd"
#set in staging files
#set :apache_proxy_port, 8000
#set :apache_proxy_servers, 2
set :apache_proxy_address, "127.0.0.1"
set :apache_ssl_enabled, false
set :apache_ssl_ip, "127.0.0.1"
set :apache_ssl_forward_all, false
#
=============================================================================
# MONGREL OPTIONS
#
=============================================================================
set(:mongrel_servers) {apache_proxy_servers}
set(:mongrel_port) {apache_proxy_port}
set :mongrel_address, apache_proxy_address
set :mongrel_environment, "production"
set(:mongrel_pid_file) {"/var/run/mongrel_cluster/#{application}.pid"}
set(:mongrel_conf) {"/etc/mongrel_cluster/#{application}.conf"}
set :mongrel_user, user
set :mongrel_group, group
#
=============================================================================
# CAPISTRANO OPTIONS
#
=============================================================================
# default_run_options[:pty] = true
set :keep_releases, 3
require 'capistrano/ext/multistage'
require 'railsmachine/recipes'
On Apr 19, 11:02 pm, Jamis Buck <[EMAIL PROTECTED]> wrote:
> Interesting, I can't duplicate this. If I add the following task to my
> deploy.rb:
>
> task :show_stage do
> puts(stage)
> end
>
> and then invoke this:
>
> cap production show_stage
>
> it correctly prints "production" to my terminal.
>
> Are you sure you've got the staging stuff configured right?
>
> - Jamis
>
> On Apr 19, 2008, at 6:34 PM, J2M wrote:
>
>
>
> > I have a multistage setup with a production.rb & testing.rb under
> > config/deploy and have set up the deploy.rb according to
> >http://weblog.jamisbuck.org/2007/7/23/capistrano-multistagebut none
> > of my custom tasks within deploy.rb can reference the variable stage
> > e.g.
>
> > namespace :nginx do
> > desc 'Setup symlinks to the sites public directory an nginx
> > config.'
> > task :setup, :roles => :app do
> > sudo "rm -f #{public_html}"
> > sudo "ln -fs #{current_path}/public #{public_html}"
> > sudo "rm -f /etc/nginx/vhosts/#{application_stage}.conf"
> > sudo "ln -fs #{current_path}/config/nginx.#{stage}.conf /etc/
> > nginx/vhosts/#{application}.#{stage}.conf"
> > end
> > end
>
> > I just get undefined local variable or method `stage' .....
>
> > How do I keep this dry and have all my custom tasks in deploy.rb
> > rather than having to put them into both deploy/production.rb and
> > deploy/testing.rb?
>
> > Thanks,
> > James
> > >
> smime.p7s
> 3KDownload
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---