I''d like to set up capistrano to send an email whenever we do a deployment. Just start an SMTP session with localhost and shoot off the email. I have all the code to do that actually, I just don''t know how to run some Ruby code on the deployment server. Anyone know how to do that, or do you have an email recipe? Pat --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 4, 2007, at 4:52 PM, Pat Maddox wrote:> > I''d like to set up capistrano to send an email whenever we do a > deployment. Just start an SMTP session with localhost and shoot off > the email. I have all the code to do that actually, I just don''t know > how to run some Ruby code on the deployment server. Anyone know how > to do that, or do you have an email recipe? > > Pat >Hey Pat- Here is a method you can use to run ruby code on the remote server: def ruby(cmd, options={}, &block) temp_name = random_string + ".rb" begin put(cmd, temp_name, :mode => 0700) send(run_method, "ruby #{temp_name}", options, &block) ensure delete temp_name end end # then in a recipe: task :foo do ruby "puts ''hello world!''" ruby <<-RUBY 1.upto(10).do |i| pust i end RUBY end Cheers- -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 3/4/07, Ezra Zygmuntowicz <ezmobius-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Mar 4, 2007, at 4:52 PM, Pat Maddox wrote: > > > > > I''d like to set up capistrano to send an email whenever we do a > > deployment. Just start an SMTP session with localhost and shoot off > > the email. I have all the code to do that actually, I just don''t know > > how to run some Ruby code on the deployment server. Anyone know how > > to do that, or do you have an email recipe? > > > > Pat > > > > Hey Pat- > > Here is a method you can use to run ruby code on the remote server: > > def ruby(cmd, options={}, &block) > temp_name = random_string + ".rb" > begin > put(cmd, temp_name, :mode => 0700) > send(run_method, "ruby #{temp_name}", options, &block) > ensure > delete temp_name > end > end > > > # then in a recipe: > > task :foo do > ruby "puts ''hello world!''" > ruby <<-RUBY > 1.upto(10).do |i| > pust i > end > RUBY > end > > Cheers- > -- Ezra Zygmuntowicz > -- Lead Rails Evangelist > -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org > -- Engine Yard, Serious Rails Hosting > -- (866) 518-YARD (9273) > > > > > >Cool, thanks, that worked. Until I needed to load up some stuff from the rails environment. Decided to use ActionMailer instead of just doing the SMTP connection. Anyway, I created a cap plugin: module CapistranoRunner def runner(cmd) run "#{release_path}/script/runner \"#{cmd}\" -e production" end end Capistrano.plugin :runner, CapistranoRunner and then to use it it looks like task :after_deploy do runner.runner "CapistranoMailer.deliver_deploy(:revision => #{revision})" cleanup end Pat --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---