heroku / heroku.rb

DEPRECATED! Official Heroku Ruby Legacy API wrapper
161 stars 41 forks source link

method to show current amount of workers #56

Open vince opened 11 years ago

vince commented 11 years ago

Looks like we can scale workers using post_ps_scale, but there doesn't seem to be a method to count the number of workers running right now. Did I miss it?

geemus commented 11 years ago

get_ps will show all your current dynos, which you can count by type to get the number you wanted. I think that is the most direct way currently.

vince commented 11 years ago

I'm not looking for dynos, I'm looking for workers. And get_ps gives me no indication that the number is 0 if none are running.

Edit: ok, apparently now dynos encompass both web and worker processes. Let me do some digging and see if I can differentiate the two.

vince commented 11 years ago

Looks like it's possible If heroku_response is the response from get_ps, here's what I have to do to get the count:

heroku_response.data[:body].map{|x| x["process"]}.reject{ |y| y.include?("web")}.count

Seems like there should be an easier way, right?

geemus commented 11 years ago

@vince - ah, got it. Sorry I kinda missed the goal there. There is a way it just isn't implemented here unfortunately. I think something along these lines would be what you wanted:

    # GET /apps/:app/formation
    def get_formation(app)
      request(
        :expects  => 200,
        :method   => :get,
        :path     => "/apps/#{app}/formation"
      )
    end

You can also avoid defining the method for now if you want and just call heroku_instance.request with those params I think. Anyway, hopefully that gets you what you need for now and we should perhaps turn that into a pull request/patch soon.