Class: Wrapbox::Runner::Ecs
- Inherits:
-
Object
- Object
- Wrapbox::Runner::Ecs
- Defined in:
- lib/wrapbox/runner/ecs.rb
Defined Under Namespace
Classes: Cli, ContainerAbnormalEnd, ExecutionFailure, ExecutionTimeout, LackResource, LaunchFailure, Parameter
Constant Summary collapse
- EXECUTION_RETRY_INTERVAL =
3
- WAIT_DELAY =
5
- HOST_TERMINATED_REASON_REGEXP =
/Host EC2.*terminated/
Instance Attribute Summary collapse
-
#additional_container_definitions ⇒ Object
readonly
Returns the value of attribute additional_container_definitions.
-
#cluster ⇒ Object
readonly
Returns the value of attribute cluster.
-
#container_definition ⇒ Object
readonly
Returns the value of attribute container_definition.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
-
#task_role_arn ⇒ Object
readonly
Returns the value of attribute task_role_arn.
Instance Method Summary collapse
-
#initialize(options) ⇒ Ecs
constructor
A new instance of Ecs.
- #run(class_name, method_name, args, container_definition_overrides: {}, **parameters) ⇒ Object
- #run_cmd(cmds, container_definition_overrides: {}, **parameters) ⇒ Object
Constructor Details
#initialize(options) ⇒ Ecs
Returns a new instance of Ecs.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/wrapbox/runner/ecs.rb', line 33 def initialize() @name = [:name] @revision = [:revision] @cluster = [:cluster] @region = [:region] @container_definition = [:container_definition] @additional_container_definitions = [:additional_container_definitions] @task_role_arn = [:task_role_arn] $stdout.sync = true @logger = Logger.new($stdout) end |
Instance Attribute Details
#additional_container_definitions ⇒ Object (readonly)
Returns the value of attribute additional_container_definitions.
24 25 26 |
# File 'lib/wrapbox/runner/ecs.rb', line 24 def additional_container_definitions @additional_container_definitions end |
#cluster ⇒ Object (readonly)
Returns the value of attribute cluster.
24 25 26 |
# File 'lib/wrapbox/runner/ecs.rb', line 24 def cluster @cluster end |
#container_definition ⇒ Object (readonly)
Returns the value of attribute container_definition.
24 25 26 |
# File 'lib/wrapbox/runner/ecs.rb', line 24 def container_definition @container_definition end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/wrapbox/runner/ecs.rb', line 24 def name @name end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
24 25 26 |
# File 'lib/wrapbox/runner/ecs.rb', line 24 def region @region end |
#revision ⇒ Object (readonly)
Returns the value of attribute revision.
24 25 26 |
# File 'lib/wrapbox/runner/ecs.rb', line 24 def revision @revision end |
#task_role_arn ⇒ Object (readonly)
Returns the value of attribute task_role_arn.
24 25 26 |
# File 'lib/wrapbox/runner/ecs.rb', line 24 def task_role_arn @task_role_arn end |
Instance Method Details
#run(class_name, method_name, args, container_definition_overrides: {}, **parameters) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/wrapbox/runner/ecs.rb', line 66 def run(class_name, method_name, args, container_definition_overrides: {}, **parameters) task_definition = register_task_definition(container_definition_overrides) parameter = Parameter.new(**parameters) run_task( task_definition.task_definition_arn, class_name, method_name, args, ["bundle", "exec", "rake", "wrapbox:run"], parameter ) end |
#run_cmd(cmds, container_definition_overrides: {}, **parameters) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/wrapbox/runner/ecs.rb', line 77 def run_cmd(cmds, container_definition_overrides: {}, **parameters) task_definition = register_task_definition(container_definition_overrides) parameter = Parameter.new(**parameters) ths = cmds.map do |cmd| Thread.new(cmd) do |c| run_task( task_definition.task_definition_arn, nil, nil, nil, c.split(/\s+/), parameter ) end end ths.each(&:join) end |