Sha256: 7d0d3092ddd2a227c2a891ebcf869672ef0f6a7214c3c4640f8709178f64e431
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
module Heroku class Commander attr_accessor :app, :logger, :config def initialize(options = {}) @app = options[:app] @logger = options[:logger] end # Returns a loaded Heroku::Config instance. def config @config ||= Heroku::Config.new({ :app => app, :logger => logger }).tap do |config| config.reload! end end def processes(&block) processes = [] cmdline = [ "heroku", "ps", @app ? "--app #{@app}" : nil ].compact.join(" ") Heroku::Executor.run cmdline, { :logger => logger } do |line| next if ! line || line[0] == '=' || line.length == 0 if (match = line.match /(\w+\.\d+): (\w+)/) process = Heroku::Process.new({ :logger => logger, :pid => match[1], :status => match[2], :app => app }) processes << process logger.info "Process: #{process.pid} (#{process.status}) from '#{line}'" if logger yield process if block_given? else logger.warn "Unexpected line from heroku ps: #{line}" if logger end end processes end # Run a process synchronously def run(command, options = {}, &block) runner = Heroku::Runner.new({ :app => app, :logger => logger, :command => command }) runner.run!(options, &block) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
heroku-commander-0.2.0 | lib/heroku/commander.rb |