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 =
<<~DESC - Runs one-off **_non-interactive_** replicas (close analog of `heroku run:detached`) - Uses `Cron` workload type with log async fetching - Implemented with only async execution methods, more suitable for production tasks - Has alternative log fetch implementation with only JSON-polling and no WebSockets - Less responsive but more stable, useful for CI tasks DESC
- EXAMPLES =
<<~EX ```sh cpl run:detached rails db:prepare -a $APP_NAME # Need to quote COMMAND if setting ENV value or passing args. cpl run:detached 'LOG_LEVEL=warn rails db:migrate' -a $APP_NAME # COMMAND may also be passed at the end (in this case, no need to quote). cpl run:detached -a $APP_NAME -- rails db:migrate # Uses some other image. cpl run:detached rails db:migrate -a $APP_NAME --image /some/full/image/path # Uses latest app image (which may not be promoted yet). cpl run:detached rails db:migrate -a $APP_NAME --image latest # Uses a different image (which may not be promoted yet). cpl run:detached rails db:migrate -a $APP_NAME --image appimage:123 # Exact image name cpl run:detached rails db:migrate -a $APP_NAME --image latest # Latest sequential image # Uses a different workload than `one_off_workload` from `.controlplane/controlplane.yml`. cpl run:detached rails db:migrate:status -a $APP_NAME -w other-workload ``` EX
- 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
-
#call ⇒ Object
rubocop:disable Metrics/MethodLength.
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, #step_error, #step_finish, terminal_size_option, upstream_token_option, use_local_token_option, version_option, #wait_for_replica, #wait_for_workload, wait_option, workload_option
Constructor Details
This class inherits a constructor from Command::Base
Instance Attribute Details
#container ⇒ Object (readonly)
Returns the value of attribute container.
48 49 50 |
# File 'lib/command/run_detached.rb', line 48 def container @container end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
48 49 50 |
# File 'lib/command/run_detached.rb', line 48 def location @location end |
#one_off ⇒ Object (readonly)
Returns the value of attribute one_off.
48 49 50 |
# File 'lib/command/run_detached.rb', line 48 def one_off @one_off end |
#workload ⇒ Object (readonly)
Returns the value of attribute workload.
48 49 50 |
# File 'lib/command/run_detached.rb', line 48 def workload @workload end |
Instance Method Details
#call ⇒ Object
rubocop:disable Metrics/MethodLength
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/command/run_detached.rb', line 50 def call # rubocop:disable Metrics/MethodLength @location = config[:default_location] @workload = config.["workload"] || config[:one_off_workload] @one_off = "#{workload}-runner-#{rand(1000..9999)}" step("Cloning workload '#{workload}' on app '#{config.[:app]}' to '#{one_off}'") do clone_workload end wait_for_workload(one_off) show_logs_waiting ensure if cp.fetch_workload(one_off) progress.puts ensure_workload_deleted(one_off) end exit(1) if @crashed end |