forked from chook/dynalite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
executable file
·49 lines (43 loc) · 2.08 KB
/
cli.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
#!/usr/bin/env node
var argv = require('minimist')(process.argv.slice(2))
if (argv.help) {
// eslint-disable-next-line no-console
return console.log([
'',
'Usage: dynalite [--port <port>] [--path <path>] [options]',
'',
'A DynamoDB http server, optionally backed by LevelDB',
'',
'Options:',
'--help Display this help message and exit',
'--port <port> The port to listen on (default: 4567)',
'--path <path> The path to use for the LevelDB store (in-memory by default)',
'--ssl Enable SSL for the web server (default: false)',
'--createTableMs <ms> Amount of time tables stay in CREATING state (default: 500)',
'--deleteTableMs <ms> Amount of time tables stay in DELETING state (default: 500)',
'--updateTableMs <ms> Amount of time tables stay in UPDATING state (default: 500)',
'--maxItemSizeKb <kb> Maximum item size (default: 400)',
'--verbose <level> Write logs (TRACE/DEBUG/INFO/WARN/ERROR/FATAL, default off)',
'--sVerbose <level> Steroid Verbose, Write logs with extra data (Same level options)',
'--dbPerTable Using separate database for each table (only for jdbc down)',
'--connectionPoolMaxSize Maximum size of jdbc connection pool (only for jdbc down)',
'',
'Report bugs at github.com/mhart/dynalite/issues',
].join('\n'))
}
// If we're PID 1, eg in a docker container, SIGINT won't end the process as usual
if (process.pid == 1) process.on('SIGINT', process.exit)
process.on('uncaughtException', function (exception) {
console.log("an Uncaught Exception occurred");
console.log(exception);
console.log(exception.stack);
process.exit(125);
});
process.on('unhandledRejection', (reason, p) => {
console.log("Unhandled Rejection at: Promise ", p, " reason: ", reason);
});
var server = require('./index.js')(argv).listen(argv.port || 4567, function() {
var address = server.address(), protocol = argv.ssl ? 'https' : 'http'
// eslint-disable-next-line no-console
console.log('Listening at %s://%s:%s', protocol, address.address, address.port)
});