I don't know why except they were defaulting to those defined in the
gem and so deploy:setup was defining the setup directories under /u/
apps/#{application} by picking up the definition for :deploy_to from
the gems deploy.rb;
_cset(:deploy_to) { "/u/apps/#{application}" }
I haven't stopped to try to figure it out (deadlines :) ), I assumed
it was the same scope problem that made me have to define all
references to stage within config/deploy/*.rb rather than being able
to define them in config/deploy.rb
-James
On Apr 20, 3:38 pm, Jamis Buck <[EMAIL PROTECTED]> wrote:
> I don't understand why you had to redefine :releases_path
> and :shared_path and all those. Those are already all defined to be
> lazily evaluated, so you've basically just duplicated their existing
> definitions. :)
>
> - Jamis
>
> On Apr 20, 2008, at 7:52 AM, J2M wrote:
>
>
>
> > Got it working by putting the definitions for all the variables that
> > are derived from stage the deploy/testing.rb & deploy/production.rb
> > and because I was modifying deploy_to I had to define all these too;
>
> > set(:application_stage) { "#{application}.#{stage}" }
> > set(:deploy_to) { "/var/sites/#{application_stage}" }
> > set(:public_html) { "/var/www/#{application_stage}" }
>
> > set(:releases_path) { File.join(deploy_to, version_dir) }
> > set(:shared_path) { File.join(deploy_to, shared_dir) }
> > set(:current_path) { File.join(deploy_to, current_dir) }
> > set(:release_path) { File.join(releases_path, release_name) }
>
> > set(:releases) { capture("ls -x
> > #{releases_path}").split.sort }
> > set(:current_release) { File.join(releases_path, releases.last) }
> > set(:previous_release) { File.join(releases_path, releases[-2]) }
>
> > set(:current_revision) { capture("cat #{current_path}/
> > REVISION").chomp }
> > set(:latest_revision) { capture("cat #{current_release}/
> > REVISION").chomp }
> > set(:previous_revision) { capture("cat #{previous_release}/
> > REVISION").chomp }
>
> > Not very dry but it is now working.
>
> > James
>
> > On Apr 20, 5:39 am, Matt R <[EMAIL PROTECTED]> wrote:
> >> Jamis,
>
> >> That did it for me!! Thanks for your help, would've never thought of
> >> that (I kinda wondered how current_path was being eval'd, but never
> >> put 2 and 2 together).
>
> >> Thanks again,
>
> >> --
> >> Matt
>
> >> On Apr 20, 12:31 am, Jamis Buck <[EMAIL PROTECTED]> wrote:
>
> >>> Yeah, I see what's going on now. Unfortunately, the "stage" variable
> >>> doesn't get set until you actually select the stage (by running e.g.
> >>> "cap staging foo" or "cap production blah"). And since you have
> >>> variables that reference :stage during the loading of the recipe,
> >>> things blow up.
>
> >>> You'll need to make sure all of the variables that refer to :stage
> >>> (either directly or indirectly) are loaded lazily. Specifically,
> >>> note
> >>> that referencing current_path causes deploy_to to be evaluated,
> >>> which
> >>> (in your case) also causes :application to be evaluated, which
> >>> evaluates :stage. So, try putting :mongrel_conf in brackets:
>
> >>> set(:mongrel_conf) { "#{current_path}/config/
> >>> mongrel_cluster.yml" }
>
> >>> Note that if you have any other variables that reference
> >>> mongrel_conf,
> >>> you could still run into problems.
>
> >>> - Jamis
>
> >>> On Apr 19, 2008, at 9:59 PM, Matt R wrote:
>
> >>>> I modified the file to look like:
> >>>> set :stages, %w(dev staging production)
> >>>> set :default_stage, 'dev'
>
> >>>> require 'capistrano/ext/multistage'
> >>>> require 'railsmachine/recipes'
>
> >>>> ##############
> >>>> ### Global Rollout options
> >>>> ##############
> >>>> ....
>
> >>>> and I still get the errors on the same line (although the line # is
> >>>> bumped up a bit! ;))
>
> >>>> Thanks for your help and making such a great tool!
>
> >>>> --
> >>>> Matt
>
> >>>> On Apr 19, 11:53 pm, Jamis Buck <[EMAIL PROTECTED]> wrote:
> >>>>> Ah, yeah. That'll fail, because when the variable is evaluated,
> >>>>> the
> >>>>> multistage code has not yet been loaded. Be sure to load the
> >>>>> multistage extension as early as possible (after
> >>>>> setting :default_stage, for instance), rather than throwing it
> >>>>> at the
> >>>>> very end.
>
> >>>>> - Jamis
>
> >>>>> On Apr 19, 2008, at 9:50 PM, Matt R wrote:
>
> >>>>>> 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-multistagebutnone
> >>>>>>>> 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
>
> ...
>
> read more »
>
> 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
-~----------~----~----~----~------~----~------~--~---