Watchbot's JavaScript API
.messages(queue, topic, stackName, backoff)
Creates messages objects
Creates messages objects
the URL of an SQS queue
the ARN of an SNS topic for failure notifications
the name of the CloudFormation stack
whether jobs retrying should be returned to SQS with exponential backoff.
object
:
a messages object
.tasks(cluster, taskDefinition, containerName, concurrency)
Creates tasks objects
Creates tasks objects
the ARN of the ECS cluster to run tasks on
the ARN of the processing TaskDefinition to run
the name of the container defined by the TaskDefinition
the desired task concurrency
object
:
a tasks object
.notifications(topic)
Creates notifications objects
Creates notifications objects
the ARN of an SNS topic to receive notifications
object
:
an notifications object
.main(config)
The main Watchbot loop
The main Watchbot loop
configuration parameters
the ARN for the notification SNS topic
the ARN for the ECS cluster
the ARN for the worker task definition
the name of the container defined by the TaskDefinition
the number of concurrent tasks
the URL for the SQS queue
the name of the CFN stack
whether to retry with backoff
info)
fastlog log level
object
:
an event emitter that will emit an finish event if the
main loop is stopped.
.end
Signals the main loop to shut down.
Signals the main loop to shut down.
.template(options)
Creates a bare-bones CloudFormation template for a Watchbot stack
Creates a bare-bones CloudFormation template for a Watchbot stack
configuration details
a description to set for the template
set to true to provide a keypair with permission to send work to the queue.
set to true to enable a webhook endpoint allowing an HTTPS POST request to add work to the queue.
require an API key in order to POST to the webhook endpoint
a set of key-value pairs to provide as environment variables to all tasks.
object
:
a CloudFormation template. JSON.stringify this object and
save it to a file in order to deploy the stack.
An SQS message tracker
.poll(max, callback)
Poll SQS to find jobs
Poll SQS to find jobs
the maximum number of jobs to take from the queue (max 10)
a function called after polling completes. The callback will be provided with an object of key-value object pairs representing environment variables (see environment) to be provided to a task
Environment variables providing SQS message details to the processing task
the SQS MessageId
the message's subject
the message's body
the time the message was sent
the time the message was first received
the number of times the message has been received
An ECS task runner and status tracker
.outcome
Possible task outcomes
Possible task outcomes
indicates that the container(s) provided an exit code 0. The SQS message should be deleted.
indicates that the container(s) provided an exit code 3. The SQS message should be deleted and a notification sent.
indicates that the container(s) provided an exit code 3. The SQS message should be deleted and a notification sent.
indicates that container(s) provided an unknown or mismatched exit code. The SQS message should be returned and a notification sent.
.poll(callback)
Checks the status of all pending tasks
Checks the status of all pending tasks
a function to handle the response. Will be provided a taskStatus object.
.run(env, callback)
Runs a task if currently below desired concurrency
Runs a task if currently below desired concurrency
An array of finishedTask objects
the difference between current and maximum desired task concurrency.
An object providing information about the outcome of a task
indentifiers for resources involved in running the task
arns.cluster string
the ECS cluster's ARN
arns.instance string
the EC2's ARN (use in ecs.describeContainerInstances requests)
arns.task string
the tasks ARN (use in ecs.describeTasks requests)
the ECS-provided reason that the task ended
key-value pairs indicating the task's environment variables
one of the outcomes defined by tasks.outcome
An notifications object