-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
69 lines (57 loc) · 1.5 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"use strict";
/* eslint-disable no-console */
const QueueManager = require("./lib/QueueManager")
, BbPromise = require("bluebird")
, minimist = require("minimist")
, _ = require("lodash");
BbPromise.config({
// Enable long stack traces
longStackTraces: true,
});
function parseArgs() {
return minimist(process.argv.slice(2), {
boolean: [ "debug" ],
alias: {
d: "debug"
},
default: {
debug: false
}
});
}
const args = parseArgs();
global.suppressLog = !args.debug;
if (_.size(args._) === 0) {
console.error("At least one queue name must be specified");
return 1;
}
const region = args.AWS_REGION || process.env.AWS_REGION;
if (!region) {
console.error("'AWS_REGION' argument or environment variable must be passed");
return 1;
}
const apiVersion = args.AWS_LAMBDA_VERSION || "2015-03-31";
if (!args.AWS_LAMBDA_VERSION) {
console.warn(`No 'AWS_LAMBDA_VERSION' argument specified, defaulting to ${apiVersion}`);
}
const redisHost = args.REDIS_HOST || "localhost";
if (!args.REDIS_HOST) {
console.warn(`No 'REDIS_HOST' argument specified, defaulting to ${redisHost}`);
}
const redisPort = args.REDIS_PORT || 6379;
if (!args.REDIS_PORT) {
console.warn(`No 'REDIS_PORT' argument specified, defaulting to ${redisPort}`);
}
const maxRetries = args.MAX_RETRIES || 2;
if (!args.MAX_RETRIES) {
console.warn(`No 'MAX_RETRIES' argument specified, defaulting to ${maxRetries}`);
}
const qm = new QueueManager({
region,
queues: args._,
maxRetries,
apiVersion,
redisHost,
redisPort
});
return qm.process();