Skip to content

Commit

Permalink
Closes #208, #207, #206, #182, #149, #72, #15
Browse files Browse the repository at this point in the history
(cherry picked from commit 8de328df79ccf52b8d612c625891555808c2fa0e)
  • Loading branch information
tapaswenipathak committed Jun 9, 2018
1 parent 48b8b0f commit ee3f0e6
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions lib/template.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';


const cf = require('@mapbox/cloudfriend');
const path = require('path');
Expand Down Expand Up @@ -35,9 +35,12 @@ const pkg = require(path.resolve(__dirname, '..', 'package.json'));
* to specify this in order to differentiate the resources.
* @param {String} [options.family] - the name of the the task definition family
* that watchbot will create revisions of.
* @param {Number|ref} [options.workers=1] - the maximum number of worker
* containers that can be launched to process jobs concurrently. This parameter
* can be provided as either a number or a reference, i.e. `{"Ref": "..."}`.
* @param {Number|ref} [options.maxSize=1] - the maximum size for the service to
* scale up to. This parameter can be provided as either a number or a reference,
* i.e. `{"Ref": "..."}`.
* @param {Number|ref} [options.minSize=1] - the minimum size for the service to
* scale down to. This parameter can be provided as either a number or a reference,
* i.e. `{"Ref": "..."}`.
* @param {String} [options.mounts=''] - if your worker containers need to mount
* files or folders from the host EC2 file system, specify those mounts with this parameter.
* A single persistent mount point can be specified as `{host location}:{container location}`,
Expand Down Expand Up @@ -97,6 +100,10 @@ const pkg = require(path.resolve(__dirname, '..', 'package.json'));
* of 1-minute periods before an alarm is triggered. The default is 1 period, or
* 1 minute. This parameter can be provided as either a number or a reference,
* i.e. `{"Ref": "..."}`.
* @param {Number|ref} [options.deadLetterThreshold=10] - Use this parameter to
* control the duration that the number of times a message is delivered to the
* source queue before being moved to the dead-letter queue. This parameter
* can be provided as either a number or a reference, i.e. `{"Ref": "..."}`.
*/
module.exports = (options = {}) => {
['service', 'serviceVersion', 'command', 'cluster'].forEach((required) => {
Expand All @@ -111,14 +118,15 @@ module.exports = (options = {}) => {
env: {},
messageTimeout: 600,
messageRetention: 1209600,
workers: 1,
maxSize: 1,
mounts: '',
privileged: false,
family: options.service,
errorThreshold: 10,
alarmThreshold: 40,
alarmPeriods: 24,
failedPlacementAlarmPeriods: 1
failedPlacementAlarmPeriods: 1,
deadletterThreshold: 10
},
options
);
Expand Down Expand Up @@ -210,7 +218,7 @@ module.exports = (options = {}) => {
MessageRetentionPeriod: options.messageRetention,
RedrivePolicy: {
deadLetterTargetArn: cf.getAtt(prefixed('DeadLetterQueue'), 'Arn'),
maxReceiveCount: 10
maxReceiveCount: options.deadletterThreshold
}
}
};
Expand Down Expand Up @@ -439,8 +447,8 @@ module.exports = (options = {}) => {
'/',
cf.getAtt(prefixed('Service'), 'Name')
]),
MinCapacity: 0,
MaxCapacity: options.workers,
MinCapacity: options.minSize,
MaxCapacity: options.maxSize,
RoleARN: cf.getAtt(prefixed('ScalingRole'), 'Arn')
}
};
Expand All @@ -457,7 +465,7 @@ module.exports = (options = {}) => {
MetricAggregationType: 'Average',
StepAdjustments: [
{
ScalingAdjustment: Math.ceil(options.workers / 10),
ScalingAdjustment: Math.ceil(options.maxSize / 10),
MetricIntervalLowerBound: 0.0
}
]
Expand Down

0 comments on commit ee3f0e6

Please sign in to comment.