-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathtessera.js
executable file
·65 lines (56 loc) · 1.81 KB
/
tessera.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
#!/usr/bin/env node
"use strict";
const { program } = require("commander");
program
.option("-C, --cache-size <SIZE>", "Set the cache size (in MB)", parseFloat, 10)
.option("-c, --config <CONFIG>", "Provide a configuration file or directory")
.option("-p, --port <PORT>", "Set the HTTP port", parseFloat, 8080)
.option("-b, --bind <HOST>", "Set the interface to listen on", "0.0.0.0")
.option("-m, --multiprocess", "Start multiple processes", false)
.option(
"-P, --processes <PROCESSES>",
"Number of processes to start",
parseFloat,
require("os").cpus().length
)
.option(
"-r, --require <MODULE>",
"Require a specific tilelive module",
(value, previous) => previous.concat([value]),
[]
)
.option(
"-S, --source-cache-size <SIZE>",
"Set the source cache size (in # of sources)",
parseFloat,
10
)
.option("-s, --socket <SOCKET>", "Listen on a Unix socket")
.version(`tessera v${require("../package.json").version}`)
.argument("[uri]", "tilelive URI to serve")
.addHelpText("after", "\nA tilelive URI or configuration file is required.");
const argv = (process.env.TESSERA_OPTS || "")
.split(" ")
.concat(process.argv.slice(2))
.filter((x) => !!x);
const opts = program.parse(argv, { from: "user" }).opts();
if (!opts.config && program.args.length === 1) {
// compatibility with nomnom's argument handling
opts.uri = program.args[0];
opts._ = program.args;
} else if (!opts.config) {
program.help();
}
if (opts.multiprocess) {
const cluster = require("cluster");
if (cluster.isMaster) {
console.log("Launching in multiprocess mode with " + opts.processes + " workers.");
for (let i = 0; i < opts.processes; i++) {
cluster.fork();
}
} else {
return require("../server")(opts);
}
} else {
return require("../server")(opts);
}