Class: Command::RunDetached
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- NAME =
"run:detached"- USAGE =
"run:detached COMMAND"- REQUIRES_ARGS =
true- OPTIONS =
[ app_option(required: true), image_option, workload_option ].freeze
- DESCRIPTION =
"Runs one-off **_non-interactive_** replicas (close analog of `heroku run:detached`)"- LONG_DESCRIPTION =
"- Runs one-off **_non-interactive_** replicas (close analog of `heroku run:detached`)\n- Uses `Cron` workload type with log async fetching\n- Implemented with only async execution methods, more suitable for production tasks\n- Has alternative log fetch implementation with only JSON-polling and no WebSockets\n- Less responsive but more stable, useful for CI tasks\n"- EXAMPLES =
"```sh\ncpl run:detached rails db:prepare -a $APP_NAME\n\n# Need to quote COMMAND if setting ENV value or passing args to command to run\ncpl run:detached 'LOG_LEVEL=warn rails db:migrate' -a $APP_NAME\n\n# Uses some other image.\ncpl run:detached rails db:migrate -a $APP_NAME --image /some/full/image/path\n\n# Uses latest app image (which may not be promoted yet).\ncpl run:detached rails db:migrate -a $APP_NAME --image latest\n\n# Uses a different image (which may not be promoted yet).\ncpl run:detached rails db:migrate -a $APP_NAME --image appimage:123 # Exact image name\ncpl run:detached rails db:migrate -a $APP_NAME --image latest # Latest sequential image\n\n# Uses a different workload\ncpl run:detached rails db:migrate:status -a $APP_NAME -w other-workload\n```\n"- WORKLOAD_SLEEP_CHECK =
2
Constants inherited from Base
Base::DEFAULT_ARGS, Base::HIDE, Base::NO_IMAGE_AVAILABLE
Instance Attribute Summary collapse
-
#container ⇒ Object
readonly
Returns the value of attribute container.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#one_off ⇒ Object
readonly
Returns the value of attribute one_off.
-
#workload ⇒ Object
readonly
Returns the value of attribute workload.
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
all_commands, all_options, all_options_by_key_name, app_option, #args_join, commit_option, #cp, #ensure_workload_deleted, image_option, #initialize, #latest_image, #latest_image_from, #latest_image_next, org_option, #perform, #progress, skip_confirm_option, #step, upstream_token_option, use_local_token_option, version_option, #wait_for, #wait_for_replica, #wait_for_workload, workload_option
Constructor Details
This class inherits a constructor from Command::Base
Instance Attribute Details
#container ⇒ Object (readonly)
Returns the value of attribute container.
45 46 47 |
# File 'lib/command/run_detached.rb', line 45 def container @container end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
45 46 47 |
# File 'lib/command/run_detached.rb', line 45 def location @location end |
#one_off ⇒ Object (readonly)
Returns the value of attribute one_off.
45 46 47 |
# File 'lib/command/run_detached.rb', line 45 def one_off @one_off end |
#workload ⇒ Object (readonly)
Returns the value of attribute workload.
45 46 47 |
# File 'lib/command/run_detached.rb', line 45 def workload @workload end |
Instance Method Details
#call ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/command/run_detached.rb', line 47 def call @location = config[:default_location] @workload = config.["workload"] || config[:one_off_workload] @one_off = "#{workload}-runner-#{rand(1000..9999)}" clone_workload wait_for_workload(one_off) show_logs_waiting ensure ensure_workload_deleted(one_off) exit(1) if @crashed end |