Re: Use Heroku gem from within application?

2010-08-13 Thread marcel
I ran into a similar need yesterday. I wanted to have a Heroku cron
task create a bundle of my app, to get a daily DB backup.

Here is my task:

task :cron = :environment do
  require 'heroku'
  heroku_username = ENV['HEROKU_USERNAME']
  heroku_password = ENV['HEROKU_PASSWORD']

  if heroku_username.nil? || heroku_password.nil?
raise Missing heroku username and/or password
  end

  puts Capturing bundle...
  heroku = Heroku::Client.new( heroku_username, heroku_password )
  bundle_name = heroku.bundle_capture bagnolia-production
  puts Finished initiating capture of bundle '#{bundle_name}'
end

--

1. Add the heroku gem to your .gems file or vendor it, so its
available to your app. Require the heroku gem.
2. create a new install of Herkou::Client, which needs your username
and password. I put mine into the app's config to keep it out of
source control.
3. call an instance method on the client object. It looks like you'll
want to use add_domain(). You can see all the methods here:

http://github.com/heroku/heroku/blob/master/lib/heroku/client.rb

-- 
You received this message because you are subscribed to the Google Groups 
Heroku group.
To post to this group, send email to her...@googlegroups.com.
To unsubscribe from this group, send email to 
heroku+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.



Re: Use Heroku gem from within application?

2010-08-13 Thread Phillip Ridlen
This really intrigued me, so I thought I'd dig into the Heroku gem (
http://github.com/heroku/heroku/blob/master/lib/heroku/client.rb) and see
what I could find.

On line 120 of client.rb (
http://github.com/heroku/heroku/blob/master/lib/heroku/client.rb#L120) there
is a function called add_domain. It looks like you can do pretty much
anything that you could do from the command line in your code. So to solve
your problem:

require 'heroku'
heroku = Heroku::Client.new(m...@domain.com,mypass)
heroku.add_domain(myapp,http://www.example.com;)

It's as simple as that! Hope that helps.

Phillip Ridlen
@philtr

On Thu, Aug 12, 2010 at 11:17 AM, Daniel Spangenberg 
daniel.spangenb...@googlemail.com wrote:

 Hey,
 look at this cool blog post, it's for an other problem,
 but I think it's that what you need.
 http://blog.darkhax.com/2010/07/30/auto-scale-your-resque-workers-on-heroku

 Mit freundlichen Grüßen
 Daniel Spangenberg
 daniel.spangenb...@gmail.com


 Am 12.08.2010 um 18:13 schrieb Brett:

  Hi all,
 
  I want to let users purchase custom domain names to access my app on
  Heroku.  When the purchase transaction takes place, I'd like to add
  the custom domain to my app in real time.  I thought of using the
  Heroku gem/command line tool from within the app, analagous to the
  command-line expression:
  heroku domains:add www.example.com
 
  Is this possible?  If so, what is the syntax?
 
  Thanks!
 
  Brett
 
 
  --
  You received this message because you are subscribed to the Google Groups
 Heroku group.
  To post to this group, send email to her...@googlegroups.com.
  To unsubscribe from this group, send email to
 heroku+unsubscr...@googlegroups.comheroku%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group at
 http://groups.google.com/group/heroku?hl=en.
 

 --
 You received this message because you are subscribed to the Google Groups
 Heroku group.
 To post to this group, send email to her...@googlegroups.com.
 To unsubscribe from this group, send email to
 heroku+unsubscr...@googlegroups.comheroku%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/heroku?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Heroku group.
To post to this group, send email to her...@googlegroups.com.
To unsubscribe from this group, send email to 
heroku+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.



Re: Use Heroku gem from within application?

2010-08-13 Thread mwhuss
We actually have done this in http://appmark.it

http://gist.github.com/522935

Remember that domain names on heroku are scoped to the user. So if the
user has example.com for another heroku app and they try to register
www.example.com with your app, it won't work.

--
Marshall
http://mwhuss.com
http://nezumiapp.com

On Aug 12, 12:13 pm, Brett brett.huneyc...@gmail.com wrote:
 Hi all,

 I want to let users purchase custom domain names to access my app on
 Heroku.  When the purchase transaction takes place, I'd like to add
 the custom domain to my app in real time.  I thought of using the
 Heroku gem/command line tool from within the app, analagous to the
 command-line expression:
 heroku domains:addwww.example.com

 Is this possible?  If so, what is the syntax?

 Thanks!

 Brett

-- 
You received this message because you are subscribed to the Google Groups 
Heroku group.
To post to this group, send email to her...@googlegroups.com.
To unsubscribe from this group, send email to 
heroku+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.



Re: Use Heroku gem from within application?

2010-08-13 Thread Phillip Ridlen
Keep in mind that you don't need to set an environment variable for
your app name. Heroku already stores it in ENV[APP_NAME].

Phillip Ridlen
@philtr

On Aug 13, 12:49 pm, mwhuss mwh...@gmail.com wrote:
 We actually have done this inhttp://appmark.it

 http://gist.github.com/522935

 Remember that domain names on heroku are scoped to the user. So if the
 user has example.com for another heroku app and they try to 
 registerwww.example.comwith your app, it won't work.

 --
 Marshallhttp://mwhuss.comhttp://nezumiapp.com

 On Aug 13, 12:10 pm, marcel mpoi...@gmail.com wrote:



  I ran into a similar need yesterday. I wanted to have a Heroku cron
  task create a bundle of my app, to get a daily DB backup.

  Here is my task:

  task :cron = :environment do
    require 'heroku'
    heroku_username = ENV['HEROKU_USERNAME']
    heroku_password = ENV['HEROKU_PASSWORD']

    if heroku_username.nil? || heroku_password.nil?
      raise Missing heroku username and/or password
    end

    puts Capturing bundle...
    heroku = Heroku::Client.new( heroku_username, heroku_password )
    bundle_name = heroku.bundle_capture bagnolia-production
    puts Finished initiating capture of bundle '#{bundle_name}'
  end

  --

  1. Add the heroku gem to your .gems file or vendor it, so its
  available to your app. Require the heroku gem.
  2. create a new install of Herkou::Client, which needs your username
  and password. I put mine into the app's config to keep it out of
  source control.
  3. call an instance method on the client object. It looks like you'll
  want to use add_domain(). You can see all the methods here:

 http://github.com/heroku/heroku/blob/master/lib/heroku/client.rb

-- 
You received this message because you are subscribed to the Google Groups 
Heroku group.
To post to this group, send email to her...@googlegroups.com.
To unsubscribe from this group, send email to 
heroku+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.



Re: Use Heroku gem from within application?

2010-08-12 Thread Daniel Spangenberg
Hey,
look at this cool blog post, it's for an other problem,
but I think it's that what you need.
http://blog.darkhax.com/2010/07/30/auto-scale-your-resque-workers-on-heroku

Mit freundlichen Grüßen
Daniel Spangenberg
daniel.spangenb...@gmail.com


Am 12.08.2010 um 18:13 schrieb Brett:

 Hi all,
 
 I want to let users purchase custom domain names to access my app on
 Heroku.  When the purchase transaction takes place, I'd like to add
 the custom domain to my app in real time.  I thought of using the
 Heroku gem/command line tool from within the app, analagous to the
 command-line expression:
 heroku domains:add www.example.com
 
 Is this possible?  If so, what is the syntax?
 
 Thanks!
 
 Brett
 
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 Heroku group.
 To post to this group, send email to her...@googlegroups.com.
 To unsubscribe from this group, send email to 
 heroku+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/heroku?hl=en.
 

-- 
You received this message because you are subscribed to the Google Groups 
Heroku group.
To post to this group, send email to her...@googlegroups.com.
To unsubscribe from this group, send email to 
heroku+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.