elastic_whenever 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +2 -2
- data/CHANGELOG.md +34 -5
- data/README.md +37 -44
- data/elastic_whenever.gemspec +1 -1
- data/lib/elastic_whenever/cli.rb +4 -6
- data/lib/elastic_whenever/option.rb +49 -1
- data/lib/elastic_whenever/schedule.rb +3 -15
- data/lib/elastic_whenever/task.rb +3 -2
- data/lib/elastic_whenever/task/target.rb +35 -4
- data/lib/elastic_whenever/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 221091fd69b334eb2e1a29e0d98f5bd8154d3a6c
|
4
|
+
data.tar.gz: ed62915c7e06921b264dc21b9646a367cc747e13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9173b91d178b252b455dd833e9d0bfdabf2dc730f593ac156c58ddc8bb55c268fcaf38614b7eda8402c8163b66a21a3caf15d114dd9b0b235b3c661853faae1d
|
7
|
+
data.tar.gz: 3bbf59e2d2265073a59159f941555f5b6b8d27934eeb6363cc692eb52172ad4f7bff4d667ef64f852d7bee1f2d00a5291967d38f8d27d7a37ed7b9e5bbc4f87a
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,45 @@
|
|
1
|
-
|
1
|
+
## v0.4.0 (2018-12-19)
|
2
2
|
|
3
|
-
|
3
|
+
Elastic Whenever now supports Fargate launch type. Thanks @avinson.
|
4
|
+
|
5
|
+
From this release, ECS parameters must be passed as arguments. Previously, it supported schedule file variables, but it will be ignored.
|
6
|
+
|
7
|
+
```
|
8
|
+
# Before
|
9
|
+
$ elastic_whenever --set 'cluster=ecs-test&task_definition=oneoff-application:2&container=oneoff'
|
10
|
+
|
11
|
+
# After
|
12
|
+
$ elastic_whenever --cluster ecs-test --task-definition oneoff-application:2 --container oneoff
|
13
|
+
```
|
14
|
+
|
15
|
+
### Enhancements
|
16
|
+
|
17
|
+
- update elastic_whenever for FARGATE launch type ([#34](https://github.com/wata727/elastic_whenever/pull/34))
|
18
|
+
|
19
|
+
### Changes
|
20
|
+
|
21
|
+
- Bump aws-sdk-cloudwatchevents dependency ([#36](https://github.com/wata727/elastic_whenever/pull/36))
|
22
|
+
- Pass ECS params as an argument ([#37](https://github.com/wata727/elastic_whenever/pull/37))
|
23
|
+
|
24
|
+
### Chore
|
25
|
+
|
26
|
+
- CI against Ruby 2.4.5 and 2.5.3 ([#35](https://github.com/wata727/elastic_whenever/pull/35))
|
27
|
+
- Set nil as verbose mode ([#38](https://github.com/wata727/elastic_whenever/pull/38))
|
28
|
+
- Revise task's target ([#39](https://github.com/wata727/elastic_whenever/pull/39))
|
29
|
+
|
30
|
+
## v0.3.2 (2018-06-25)
|
31
|
+
|
32
|
+
### BugFix
|
4
33
|
|
5
34
|
- fix: `Task::Role#exists?` always return true ([#33](https://github.com/wata727/elastic_whenever/pull/33))
|
6
35
|
|
7
|
-
|
36
|
+
## v0.3.1 (2018-06-25)
|
8
37
|
|
9
|
-
|
38
|
+
### BugFix
|
10
39
|
|
11
40
|
- add `attr_reader :enviroment` ([#32](https://github.com/wata727/elastic_whenever/pull/32))
|
12
41
|
|
13
|
-
|
42
|
+
### Others
|
14
43
|
|
15
44
|
- CI against Ruby 2.5 ([#30](https://github.com/wata727/elastic_whenever/pull/30))
|
16
45
|
- Use `File.exist?` instead of `File.exists?` ([#31](https://github.com/wata727/elastic_whenever/pull/31))
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE.txt)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/elastic_whenever.svg)](https://badge.fury.io/rb/elastic_whenever)
|
5
5
|
|
6
|
-
Manage ECS scheduled tasks like whenever gem.
|
6
|
+
Manage ECS scheduled tasks like [Whenever](https://github.com/javan/whenever) gem.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
@@ -23,7 +23,7 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
|
26
|
-
You can use it almost like
|
26
|
+
You can use it almost like Whenever. However, please be aware that you must specify an identifier.
|
27
27
|
|
28
28
|
```
|
29
29
|
$ elastic_whenever --help
|
@@ -31,7 +31,16 @@ Usage: elastic_whenever [options]
|
|
31
31
|
-i, --update identifier Clear and create scheduled tasks by schedule file
|
32
32
|
-c, --clear identifier Clear scheduled tasks
|
33
33
|
-l, --list identifier List scheduled tasks
|
34
|
-
-s, --set variables Example: --set 'environment=staging
|
34
|
+
-s, --set variables Example: --set 'environment=staging'
|
35
|
+
--cluster cluster ECS cluster to run tasks
|
36
|
+
--task-definition task_definition
|
37
|
+
Task definition name, If omit a revision, use the latest revision of the family automatically. Example: --task-deifinition oneoff-application:2
|
38
|
+
--container container Container name defined in the task definition
|
39
|
+
--launch-type launch_type Launch type. EC2 or FARGATE. Defualt: EC2
|
40
|
+
--assign-public-ip Assign a public IP. Default: DISABLED (FARGATE only)
|
41
|
+
--security-groups groups Example: --security-groups 'sg-2c503655,sg-72f0cb0a' (FARGATE only)
|
42
|
+
--subnets subnets Example: --subnets 'subnet-4973d63f,subnet-45827d1d' (FARGATE only)
|
43
|
+
--platform-version version Optionally specify the platform version. Default: LATEST (FARGATE only)
|
35
44
|
-f, --file schedule_file Default: config/schedule.rb
|
36
45
|
--profile profile_name AWS shared profile name
|
37
46
|
--access-key aws_access_key_id
|
@@ -40,30 +49,13 @@ Usage: elastic_whenever [options]
|
|
40
49
|
AWS secret access key
|
41
50
|
--region region AWS region
|
42
51
|
-v, --version Print version
|
52
|
+
-V, --verbose Run rake jobs without --silent
|
43
53
|
```
|
44
54
|
|
45
|
-
|
46
|
-
|
47
|
-
```ruby
|
48
|
-
set :cluster, 'ecs-test' # ECS cluster name
|
49
|
-
set :task_definition, 'oneoff-application:2' # Task definition name, If omit the revision, use the latest revision of family automatically.
|
50
|
-
set :container, 'oneoff' # Container name of task definition
|
51
|
-
|
52
|
-
every :day, at: '03:00am' do
|
53
|
-
runner 'Hoge.run'
|
54
|
-
end
|
55
|
-
```
|
56
|
-
|
57
|
-
If you do not write it in the schedule file, specify it with arguments.
|
55
|
+
NOTE: Currently, Elastic Whenever supports the Whenever syntax partially. We strongly encourage to use dry-run mode for verifying tasks to be created.
|
58
56
|
|
59
57
|
```
|
60
|
-
$ elastic_whenever
|
61
|
-
```
|
62
|
-
|
63
|
-
NOTE: Currently, it supports only the syntax of whenever partially. We recommend to check what happens beforehand with the `elastic_whenever` command.
|
64
|
-
|
65
|
-
```
|
66
|
-
$ elastic_whenever
|
58
|
+
$ elastic_whenever --cluster ecs-test --task-definition example:2 --container cron
|
67
59
|
cron(0 3 * * ? *) ecs-test example:2 cron bundle exec rake hoge:run
|
68
60
|
|
69
61
|
## [message] Above is your schedule file converted to scheduled tasks; your scheduled tasks was not updated.
|
@@ -71,7 +63,7 @@ cron(0 3 * * ? *) ecs-test example:2 cron bundle exec rake hoge:run
|
|
71
63
|
```
|
72
64
|
|
73
65
|
## How it works
|
74
|
-
Elastic Whenever creates CloudWatch Events as many as `every` block.
|
66
|
+
Elastic Whenever creates CloudWatch Events as many as `every` block. Each event has as many targets as there are commands in the block.
|
75
67
|
|
76
68
|
```ruby
|
77
69
|
every '0 0 * * *' do # scheduled task (identifier_68237a3b152a6c44359e1cf5cd8e7cf0def303d7)
|
@@ -80,20 +72,21 @@ every '0 0 * * *' do # scheduled task (identifier_68237a3b152a6c44359e1cf5cd8e7c
|
|
80
72
|
end
|
81
73
|
```
|
82
74
|
|
83
|
-
The
|
84
|
-
|
75
|
+
The scheduled task's name is a digest value calculated from an identifier, commands, and so on.
|
76
|
+
|
77
|
+
NOTE: You should not use the same identifier across different clusters because CloudWatch Events rule names are unique across all clusters.
|
85
78
|
|
86
79
|
## Compatible with Whenever
|
87
|
-
### `job_type`
|
88
|
-
Whenever supports custom job type
|
80
|
+
### `job_type`
|
81
|
+
Whenever supports custom job type with `job_type` method, but Elastic Whenever doesn't support it.
|
89
82
|
|
90
83
|
```ruby
|
91
84
|
# [warn] Skipping unsupported method: job_type
|
92
85
|
job_type :awesome, '/usr/local/bin/awesome :task :fun_level'
|
93
86
|
```
|
94
87
|
|
95
|
-
### `env`
|
96
|
-
Whenever supports environment variables
|
88
|
+
### `env`
|
89
|
+
Whenever supports environment variables with `env` method, but Elastic Whenever doesn't support it.
|
97
90
|
You should use task definitions to set environment variables.
|
98
91
|
|
99
92
|
```ruby
|
@@ -101,16 +94,16 @@ You should use task definitions to set environment variables.
|
|
101
94
|
env "VERSION", "v1"
|
102
95
|
```
|
103
96
|
|
104
|
-
### `:job_template`
|
105
|
-
Whenever has a template to describe as cron, but Elastic Whenever
|
97
|
+
### `:job_template`
|
98
|
+
Whenever has a template to describe as cron, but Elastic Whenever doesn't have the template.
|
106
99
|
Therefore, `:job_template` option is ignored.
|
107
100
|
|
108
101
|
```ruby
|
109
102
|
set :job_template, "/bin/zsh -l -c ':job'" # ignored
|
110
103
|
```
|
111
104
|
|
112
|
-
###
|
113
|
-
Elastic Whenever processes
|
105
|
+
### Frequency
|
106
|
+
Elastic Whenever processes frequency passed to `every` block almost like Whenever.
|
114
107
|
|
115
108
|
```ruby
|
116
109
|
# Whenever
|
@@ -134,7 +127,7 @@ every 10.minutes do
|
|
134
127
|
end
|
135
128
|
```
|
136
129
|
|
137
|
-
However, handling of the day of week is partially different because it follows
|
130
|
+
However, handling of the day of week is partially different because it follows scheduled expression.
|
138
131
|
|
139
132
|
```ruby
|
140
133
|
# Whenever
|
@@ -148,7 +141,7 @@ every :monday do
|
|
148
141
|
end
|
149
142
|
```
|
150
143
|
|
151
|
-
Therefore,
|
144
|
+
Therefore, cron syntax is converted to scheduled expression like the following:
|
152
145
|
|
153
146
|
```ruby
|
154
147
|
# cron(0 0 ? * 2 *) ecs-test myapp:2 web awesome
|
@@ -157,7 +150,7 @@ every "0 0 * * 1" do
|
|
157
150
|
end
|
158
151
|
```
|
159
152
|
|
160
|
-
|
153
|
+
Absolutely, you can also write scheduled expression.
|
161
154
|
|
162
155
|
```ruby
|
163
156
|
# cron(0 0 ? * 2 *) ecs-test myapp:2 web awesome
|
@@ -166,8 +159,8 @@ every "0 0 ? * 2 *" do
|
|
166
159
|
end
|
167
160
|
```
|
168
161
|
|
169
|
-
#### `:reboot`
|
170
|
-
Whenever supports `:reboot`
|
162
|
+
#### `:reboot`
|
163
|
+
Whenever supports `:reboot` as a cron option, but Elastic Whenever doesn't support it.
|
171
164
|
|
172
165
|
```ruby
|
173
166
|
# [warn] `reboot` is not supported option. Ignore this task.
|
@@ -176,9 +169,9 @@ every :reboot do
|
|
176
169
|
end
|
177
170
|
```
|
178
171
|
|
179
|
-
###
|
180
|
-
Whenever checks if the application uses bundler and automatically adds
|
181
|
-
However, Elastic Whenever always adds
|
172
|
+
### Bundle commands
|
173
|
+
Whenever checks if the application uses bundler and automatically adds a prefix to commands.
|
174
|
+
However, Elastic Whenever always adds a prefix on a premise that the application is using bundler.
|
182
175
|
|
183
176
|
```ruby
|
184
177
|
# Whenever
|
@@ -197,8 +190,8 @@ If you don't want to add the prefix, set `bundle_command` to empty as follows:
|
|
197
190
|
set :bundle_command, ""
|
198
191
|
```
|
199
192
|
|
200
|
-
###
|
201
|
-
Whenever supports `runner` job with old Rails
|
193
|
+
### Rails
|
194
|
+
Whenever supports `runner` job with old Rails versions, but Elastic Whenever supports Rails 4 and above only.
|
202
195
|
|
203
196
|
```ruby
|
204
197
|
# Whenever
|
data/elastic_whenever.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.0"
|
26
26
|
|
27
27
|
spec.add_dependency "aws-sdk-ecs", "~> 1.0"
|
28
|
-
spec.add_dependency "aws-sdk-cloudwatchevents", "~> 1.
|
28
|
+
spec.add_dependency "aws-sdk-cloudwatchevents", "~> 1.5"
|
29
29
|
spec.add_dependency "aws-sdk-iam", "~> 1.0"
|
30
30
|
spec.add_dependency "chronic", "~> 0.10"
|
31
31
|
end
|
data/lib/elastic_whenever/cli.rb
CHANGED
@@ -36,7 +36,6 @@ module ElasticWhenever
|
|
36
36
|
ERROR_EXIT_CODE
|
37
37
|
rescue OptionParser::MissingArgument,
|
38
38
|
Option::InvalidOptionException,
|
39
|
-
Schedule::InvalidScheduleException,
|
40
39
|
Task::Target::InvalidContainerException => exn
|
41
40
|
|
42
41
|
Logger.instance.fail(exn.message)
|
@@ -46,11 +45,10 @@ module ElasticWhenever
|
|
46
45
|
private
|
47
46
|
|
48
47
|
def update_tasks(option, dry_run:)
|
49
|
-
schedule = Schedule.new(option.schedule_file, option.variables)
|
50
|
-
schedule.validate!
|
48
|
+
schedule = Schedule.new(option.schedule_file, option.verbose, option.variables)
|
51
49
|
|
52
|
-
cluster = Task::Cluster.new(option,
|
53
|
-
definition = Task::Definition.new(option,
|
50
|
+
cluster = Task::Cluster.new(option, option.cluster)
|
51
|
+
definition = Task::Definition.new(option, option.task_definition)
|
54
52
|
role = Task::Role.new(option)
|
55
53
|
if !role.exists? && !dry_run
|
56
54
|
role.create
|
@@ -64,7 +62,7 @@ module ElasticWhenever
|
|
64
62
|
option,
|
65
63
|
cluster: cluster,
|
66
64
|
definition: definition,
|
67
|
-
container:
|
65
|
+
container: option.container,
|
68
66
|
commands: command,
|
69
67
|
rule: rule,
|
70
68
|
role: role,
|
@@ -8,7 +8,16 @@ module ElasticWhenever
|
|
8
8
|
|
9
9
|
attr_reader :identifier
|
10
10
|
attr_reader :mode
|
11
|
+
attr_reader :verbose
|
11
12
|
attr_reader :variables
|
13
|
+
attr_reader :cluster
|
14
|
+
attr_reader :task_definition
|
15
|
+
attr_reader :container
|
16
|
+
attr_reader :assign_public_ip
|
17
|
+
attr_reader :launch_type
|
18
|
+
attr_reader :platform_version
|
19
|
+
attr_reader :security_groups
|
20
|
+
attr_reader :subnets
|
12
21
|
attr_reader :schedule_file
|
13
22
|
|
14
23
|
class InvalidOptionException < StandardError; end
|
@@ -16,7 +25,16 @@ module ElasticWhenever
|
|
16
25
|
def initialize(args)
|
17
26
|
@identifier = nil
|
18
27
|
@mode = DRYRUN_MODE
|
28
|
+
@verbose = false
|
19
29
|
@variables = []
|
30
|
+
@cluster = nil
|
31
|
+
@task_definition = nil
|
32
|
+
@container = nil
|
33
|
+
@assign_public_ip = 'DISABLED'
|
34
|
+
@launch_type = 'EC2'
|
35
|
+
@platform_version = 'LATEST'
|
36
|
+
@security_groups = []
|
37
|
+
@subnets = []
|
20
38
|
@schedule_file = 'config/schedule.rb'
|
21
39
|
@profile = nil
|
22
40
|
@access_key = nil
|
@@ -36,7 +54,7 @@ module ElasticWhenever
|
|
36
54
|
@identifier = identifier
|
37
55
|
@mode = LIST_MODE
|
38
56
|
end
|
39
|
-
opts.on('-s' ,'--set variables', "Example: --set 'environment=staging
|
57
|
+
opts.on('-s' ,'--set variables', "Example: --set 'environment=staging'") do |set|
|
40
58
|
pairs = set.split('&')
|
41
59
|
pairs.each do |pair|
|
42
60
|
unless pair.include?('=')
|
@@ -47,6 +65,30 @@ module ElasticWhenever
|
|
47
65
|
@variables << { key: key, value: value }
|
48
66
|
end
|
49
67
|
end
|
68
|
+
opts.on('--cluster cluster', 'ECS cluster to run tasks') do |cluster|
|
69
|
+
@cluster = cluster
|
70
|
+
end
|
71
|
+
opts.on('--task-definition task_definition', 'Task definition name, If omit a revision, use the latest revision of the family automatically. Example: --task-deifinition oneoff-application:2') do |definition|
|
72
|
+
@task_definition = definition
|
73
|
+
end
|
74
|
+
opts.on('--container container', 'Container name defined in the task definition') do |container|
|
75
|
+
@container = container
|
76
|
+
end
|
77
|
+
opts.on('--launch-type launch_type', 'Launch type. EC2 or FARGATE. Defualt: EC2') do |launch_type|
|
78
|
+
@launch_type = launch_type
|
79
|
+
end
|
80
|
+
opts.on('--assign-public-ip', 'Assign a public IP. Default: DISABLED (FARGATE only)') do
|
81
|
+
@assign_public_ip = 'ENABLED'
|
82
|
+
end
|
83
|
+
opts.on('--security-groups groups', "Example: --security-groups 'sg-2c503655,sg-72f0cb0a' (FARGATE only)") do |groups|
|
84
|
+
@security_groups = groups.split(',')
|
85
|
+
end
|
86
|
+
opts.on('--subnets subnets', "Example: --subnets 'subnet-4973d63f,subnet-45827d1d' (FARGATE only)") do |subnets|
|
87
|
+
@subnets = subnets.split(',')
|
88
|
+
end
|
89
|
+
opts.on('--platform-version version', "Optionally specify the platform version. Default: LATEST (FARGATE only)") do |version|
|
90
|
+
@platform_version = version
|
91
|
+
end
|
50
92
|
opts.on('-f', '--file schedule_file', 'Default: config/schedule.rb') do |file|
|
51
93
|
@schedule_file = file
|
52
94
|
end
|
@@ -65,6 +107,9 @@ module ElasticWhenever
|
|
65
107
|
opts.on('-v', '--version', 'Print version') do
|
66
108
|
@mode = PRINT_VERSION_MODE
|
67
109
|
end
|
110
|
+
opts.on('-V', '--verbose', 'Run rake jobs without --silent') do
|
111
|
+
@verbose = true
|
112
|
+
end
|
68
113
|
end.parse(args)
|
69
114
|
|
70
115
|
@credentials = if profile
|
@@ -80,6 +125,9 @@ module ElasticWhenever
|
|
80
125
|
|
81
126
|
def validate!
|
82
127
|
raise InvalidOptionException.new("Can't find file: #{schedule_file}") unless File.exist?(schedule_file)
|
128
|
+
raise InvalidOptionException.new("You must set cluster") unless cluster
|
129
|
+
raise InvalidOptionException.new("You must set task definition") unless task_definition
|
130
|
+
raise InvalidOptionException.new("You must set container") unless container
|
83
131
|
end
|
84
132
|
|
85
133
|
private
|
@@ -1,14 +1,10 @@
|
|
1
1
|
module ElasticWhenever
|
2
2
|
class Schedule
|
3
3
|
attr_reader :tasks
|
4
|
-
attr_reader :cluster
|
5
|
-
attr_reader :task_definition
|
6
|
-
attr_reader :container
|
7
4
|
attr_reader :chronic_options
|
8
5
|
attr_reader :bundle_command
|
9
6
|
attr_reader :environment
|
10
7
|
|
11
|
-
class InvalidScheduleException < StandardError; end
|
12
8
|
class UnsupportedFrequencyException < StandardError; end
|
13
9
|
|
14
10
|
module WheneverNumeric
|
@@ -51,12 +47,10 @@ module ElasticWhenever
|
|
51
47
|
end
|
52
48
|
using WheneverNumeric
|
53
49
|
|
54
|
-
def initialize(file, variables)
|
50
|
+
def initialize(file, verbose, variables)
|
55
51
|
@environment = "production"
|
52
|
+
@verbose = verbose
|
56
53
|
@tasks = []
|
57
|
-
@cluster = nil
|
58
|
-
@task_definition = nil
|
59
|
-
@container = nil
|
60
54
|
@chronic_options = {}
|
61
55
|
@bundle_command = "bundle exec"
|
62
56
|
|
@@ -69,19 +63,13 @@ module ElasticWhenever
|
|
69
63
|
end
|
70
64
|
|
71
65
|
def every(frequency, options = {}, &block)
|
72
|
-
@tasks << Task.new(@environment, @bundle_command, schedule_expression(frequency, options)).tap do |task|
|
66
|
+
@tasks << Task.new(@environment, @verbose, @bundle_command, schedule_expression(frequency, options)).tap do |task|
|
73
67
|
task.instance_eval(&block)
|
74
68
|
end
|
75
69
|
rescue UnsupportedFrequencyException => exn
|
76
70
|
Logger.instance.warn(exn.message)
|
77
71
|
end
|
78
72
|
|
79
|
-
def validate!
|
80
|
-
raise InvalidScheduleException.new("You must set cluster") unless cluster
|
81
|
-
raise InvalidScheduleException.new("You must set task definition") unless task_definition
|
82
|
-
raise InvalidScheduleException.new("You must set container") unless container
|
83
|
-
end
|
84
|
-
|
85
73
|
def schedule_expression(frequency, options)
|
86
74
|
opts = { :now => Time.new(2017, 12, 1, 0, 0, 0) }.merge(@chronic_options)
|
87
75
|
time = Chronic.parse(options[:at], opts) || Time.new(2017, 12, 1, 0, 0, 0)
|
@@ -3,8 +3,9 @@ module ElasticWhenever
|
|
3
3
|
attr_reader :commands
|
4
4
|
attr_reader :expression
|
5
5
|
|
6
|
-
def initialize(environment, bundle_command, expression)
|
6
|
+
def initialize(environment, verbose, bundle_command, expression)
|
7
7
|
@environment = environment
|
8
|
+
@verbose_mode = verbose ? nil : "--silent"
|
8
9
|
@bundle_command = bundle_command.split(" ")
|
9
10
|
@expression = expression
|
10
11
|
@commands = []
|
@@ -15,7 +16,7 @@ module ElasticWhenever
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def rake(task)
|
18
|
-
@commands << [@bundle_command, "rake", task,
|
19
|
+
@commands << [@bundle_command, "rake", task, @verbose_mode].flatten.compact
|
19
20
|
end
|
20
21
|
|
21
22
|
def runner(src)
|
@@ -5,6 +5,11 @@ module ElasticWhenever
|
|
5
5
|
attr_reader :definition
|
6
6
|
attr_reader :container
|
7
7
|
attr_reader :commands
|
8
|
+
attr_reader :assign_public_ip
|
9
|
+
attr_reader :launch_type
|
10
|
+
attr_reader :platform_version
|
11
|
+
attr_reader :security_groups
|
12
|
+
attr_reader :subnets
|
8
13
|
|
9
14
|
class InvalidContainerException < StandardError; end
|
10
15
|
|
@@ -37,6 +42,11 @@ module ElasticWhenever
|
|
37
42
|
@commands = commands
|
38
43
|
@rule = rule
|
39
44
|
@role = role
|
45
|
+
@assign_public_ip = option.assign_public_ip
|
46
|
+
@launch_type = option.launch_type
|
47
|
+
@platform_version = option.platform_version
|
48
|
+
@security_groups = option.security_groups
|
49
|
+
@subnets = option.subnets
|
40
50
|
@client = Aws::CloudWatchEvents::Client.new(option.aws_config)
|
41
51
|
end
|
42
52
|
|
@@ -49,10 +59,7 @@ module ElasticWhenever
|
|
49
59
|
arn: cluster.arn,
|
50
60
|
input: input_json(container, commands),
|
51
61
|
role_arn: role.arn,
|
52
|
-
ecs_parameters:
|
53
|
-
task_definition_arn: definition.arn,
|
54
|
-
task_count: 1,
|
55
|
-
}
|
62
|
+
ecs_parameters: ecs_parameters,
|
56
63
|
}
|
57
64
|
]
|
58
65
|
)
|
@@ -71,6 +78,30 @@ module ElasticWhenever
|
|
71
78
|
}.to_json
|
72
79
|
end
|
73
80
|
|
81
|
+
def ecs_parameters
|
82
|
+
if launch_type == "FARGATE"
|
83
|
+
{
|
84
|
+
launch_type: launch_type,
|
85
|
+
task_definition_arn: definition.arn,
|
86
|
+
task_count: 1,
|
87
|
+
network_configuration: {
|
88
|
+
awsvpc_configuration: {
|
89
|
+
subnets: subnets,
|
90
|
+
security_groups: security_groups,
|
91
|
+
assign_public_ip: assign_public_ip,
|
92
|
+
}
|
93
|
+
},
|
94
|
+
platform_version: platform_version,
|
95
|
+
}
|
96
|
+
else
|
97
|
+
{
|
98
|
+
launch_type: launch_type,
|
99
|
+
task_definition_arn: definition.arn,
|
100
|
+
task_count: 1,
|
101
|
+
}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
74
105
|
attr_reader :rule
|
75
106
|
attr_reader :role
|
76
107
|
attr_reader :client
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic_whenever
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuma Watanabe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.5'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.5'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: aws-sdk-iam
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
version: '0'
|
160
160
|
requirements: []
|
161
161
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.
|
162
|
+
rubygems_version: 2.6.11
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: Manage ECS Scheduled Tasks like Whenever
|