Class: Heroku::Command::Run

Inherits:
Base
  • Object
show all
Defined in:
lib/heroku/command/run.rb

Overview

run one-off commands (console, rake)

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Instance Method Summary collapse

Methods inherited from Base

#api, #app, #heroku, #initialize, namespace, #org, #org_api

Methods included from Helpers

#action, #app_owner, #ask, #confirm, #confirm_command, #create_git_remote, #debug, #debugging?, #default_org_host, #deprecate, #display, #display_header, #display_object, #display_row, #display_table, #error, #error_log, #error_log_path, error_with_failure, error_with_failure=, extended, extended_into, #fail, #format_bytes, #format_date, #format_error, #format_with_bang, #get_terminal_environment, #git, #has_git?, #has_git_remote?, #has_http_git_entry_in_netrc, #home_directory, #hprint, #hputs, included, included_into, #json_decode, #json_encode, #launchy, #line_formatter, #longest, #org?, #org_host, #output_with_bang, #quantify, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #set_buffer, #shell, #spinner, #status, #stderr_print, #stderr_puts, #string_distance, #styled_array, #styled_error, #styled_hash, #styled_header, #suggestion, #time_ago, #truncate, #update_git_remote, #warn_if_using_jruby, #with_tty

Constructor Details

This class inherits a constructor from Heroku::Command::Base

Instance Method Details

#consoleObject

run:console [COMMAND]

open a remote console session

if COMMAND is specified, run the command and exit

NOTE: For Cedar apps, use `heroku run console`

Examples:

$ heroku console Ruby console for example.heroku.com >>


115
116
117
118
119
120
121
# File 'lib/heroku/command/run.rb', line 115

def console
  puts "`heroku #{current_command}` has been removed. Please use: `heroku run` instead."
  puts "For more information, please see:"
  puts " * https://devcenter.heroku.com/articles/one-off-dynos"
  puts " * https://devcenter.heroku.com/articles/rails3#console"
  puts " * https://devcenter.heroku.com/articles/console-bamboo"
end

#detachedObject

run:detached COMMAND

run a detached dyno, where output is sent to your logs

-s, –size SIZE # specify dyno size -t, –tail # stream logs for the dyno

Example:

$ heroku run:detached ls Running `ls` detached… up, run.1 Use `heroku logs -p run.1` to view the output.


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/heroku/command/run.rb', line 57

def detached
  command = args.join(" ")
  error("Usage: heroku run COMMAND") if command.empty?
  opts = { :attach => false, :command => command }
  opts[:size] = options[:size] if options[:size]

  app_name = app
  process_data = action("Running `#{command}` detached", :success => "up") do
    process_data = api.post_ps(app_name, command, opts).body
    status(process_data['process'])
    process_data
  end
  if options[:tail]
    opts = []
    opts << "tail=1"
    opts << "ps=#{process_data['process']}"
    log_displayer = ::Heroku::Helpers::LogDisplayer.new(heroku, app, opts)
    log_displayer.display_logs
  else
    display("Use `heroku logs -p #{process_data['process']} -a #{app_name}` to view the output.")
  end
end

#indexObject

run COMMAND

run an attached dyno

-s, –size SIZE # specify dyno size

Example:

$ heroku run bash Running `bash` attached to terminal… up, run.1 ~ $


37
38
39
40
41
42
# File 'lib/heroku/command/run.rb', line 37

def index
  command = args.join(" ")
  error("Usage: heroku run COMMAND") if command.empty?
  warn_if_using_jruby
  run_attached(command)
end

#rakeObject

run:rake COMMAND

WARNING: `heroku run:rake` has been deprecated. Please use `heroku run rake` instead.“

remotely execute a rake command

Example:

$ heroku run:rake -T Running `rake -T` attached to terminal… up, run.1 (in /app) rake test # run tests


93
94
95
96
97
# File 'lib/heroku/command/run.rb', line 93

def rake
  deprecate("`heroku #{current_command}` has been deprecated. Please use `heroku run rake` instead.")
  command = "rake #{args.join(' ')}"
  run_attached(command)
end