-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartLambda.js
executable file
·78 lines (70 loc) · 2.39 KB
/
startLambda.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
70
71
72
73
74
75
76
77
78
#!/usr/bin/env node
//this file contain bugs
/**
* This file is part of Lambdazio.
* Copyright (C) 2020 Alberto Mesillo Mesin
* Lambdazio is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Lambdazio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Lambdazio. If not, see <https://www.gnu.org/licenses/>.
*/
"use strict";
const configurations = require( "./etc/config.json" );
const Utils = require( "./includes/utils" );
const Lambda = require( "./includes/lambda/lambda" );
let options = {
functionName : null,
streamName : null,
kinesaPort : null,
lambdasStorage : __dirname + "/" + configurations.lambdaFs
};
let printHelp = () => {
console.log(
"=== Options ===\n",
"--stream-name <stream_name> mandatory - the name of the kinesalite/kinesis stream to use as data source.\n",
"--function-name <function_name> mandatory - the name of lambda function to trigger.\n",
"--kinesa-port <portnum> - the listening port for kinesalite endpoint.\n",
"--enable-cow - print the Cow.\n",
"--help - print this help. :-)"
// TODO: help for fs options...
);
process.exit( 0 );
};
if( process.env.hasOwnProperty( "LAMBDA_STORAGE" ) ) {
console.info( `Using lambda in ${process.env.LAMBDA_STORAGE}` );
options.lambdasStorage = process.env.LAMBDA_STORAGE;
}
for( let i = 0 ; i < process.argv.length ; i++ ) {
switch( process.argv[ i ] ) {
case "--function-name":
options.functionName = process.argv[++i];
break;
case "--stream-name":
options.streamName = process.argv[++i];
break;
case "--lambda-storage":
options.lambdasStorage = process.argv[++i];
break;
case "--kinesa-port":
options.kinesaPort = process.argv[++i];
break;
//// ???? ////
case "--enable-cow":
Utils.printCow( "Running the Lambda code..." );
break;
//// HELP ////
case "--help":
printHelp();
break;
}
}
///// Main Task /////
Lambda.runLambdaProcess( options );