chiitiler 1.24.0 → 1.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -8
- package/dist/cli.js +27 -8
- package/dist/main.js +4 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -158,10 +158,12 @@ All options can be set via CLI flag or environment variable.
|
|
|
158
158
|
| `--port <n>` | `CHIITILER_PORT` | `3000` |
|
|
159
159
|
| `--debug` | `CHIITILER_DEBUG` | `false` |
|
|
160
160
|
| `--user-agent <ua>` | `CHIITILER_USER_AGENT` | (none) |
|
|
161
|
-
|
|
|
162
|
-
|
|
|
161
|
+
| `--prewarm [true\|false]` | `CHIITILER_PREWARM` | `true` |
|
|
162
|
+
| `--processes <n>` | `CHIITILER_PROCESSES` | `1` (set `0` for all CPUs) |
|
|
163
163
|
|
|
164
|
-
Prewarm is enabled by default: one tile is rendered at startup **before** the server starts listening, moving shared renderer initialization work into startup.
|
|
164
|
+
Prewarm is enabled by default: one tile is rendered at startup **before** the server starts listening, moving shared renderer initialization work into startup. `--prewarm false` or `CHIITILER_PREWARM=false` disables it. `--prewarm` alone enables it. The CLI flag takes precedence over the environment variable. Style-specific tiles, glyphs, and sprites are not preloaded.
|
|
165
|
+
|
|
166
|
+
`--processes` takes precedence over `CHIITILER_PROCESSES` and accepts non-negative integers; `0` uses all available CPUs.
|
|
165
167
|
|
|
166
168
|
### Cache
|
|
167
169
|
|
|
@@ -170,8 +172,8 @@ Prewarm is enabled by default: one tile is rendered at startup **before** the se
|
|
|
170
172
|
| `--cache <none\|memory\|file\|s3\|gcs>` | `CHIITILER_CACHE_METHOD` | `none` |
|
|
171
173
|
| `--cache-ttl <seconds>` | `CHIITILER_CACHE_TTL_SEC` | `3600` |
|
|
172
174
|
| `--memory-cache-max-item-count <n>` | `CHIITILER_MEMORYCACHE_MAXITEMCOUNT` | `1000` |
|
|
173
|
-
|
|
|
174
|
-
|
|
|
175
|
+
| `--front-cache-ttl-sec <seconds>` | `CHIITILER_FRONT_CACHE_TTL_SEC` | `10` (seconds) |
|
|
176
|
+
| `--front-cache-max-bytes <bytes>` | `CHIITILER_FRONT_CACHE_MAX_BYTES` | `67108864` (64 MiB) |
|
|
175
177
|
| `--file-cache-dir <dir>` | `CHIITILER_FILECACHE_DIR` | `./.cache` |
|
|
176
178
|
| `--s3-cache-bucket <name>` | `CHIITILER_S3CACHE_BUCKET` | — |
|
|
177
179
|
| `--s3-region <region>` | `CHIITILER_S3_REGION` | `us-east-1` |
|
|
@@ -192,9 +194,9 @@ hits into memory; writes populate memory immediately and also write to the backi
|
|
|
192
194
|
cache. `none` and `memory` keep their existing behavior. This affects sources that
|
|
193
195
|
already use the cache, not direct `s3://`, `gs://`, or local source reads.
|
|
194
196
|
|
|
195
|
-
Set `CHIITILER_FRONT_CACHE_TTL_SEC` to a positive, finite number of seconds and
|
|
196
|
-
`CHIITILER_FRONT_CACHE_MAX_BYTES` to a positive integer number of bytes to override
|
|
197
|
-
these limits. Setting either
|
|
197
|
+
Set `--front-cache-ttl-sec` / `CHIITILER_FRONT_CACHE_TTL_SEC` to a positive, finite number of seconds and
|
|
198
|
+
`--front-cache-max-bytes` / `CHIITILER_FRONT_CACHE_MAX_BYTES` to a positive integer number of bytes to override
|
|
199
|
+
these limits. CLI flags take precedence over environment variables. Setting either limit to `0` disables the front cache and uses the
|
|
198
200
|
backing cache directly. Otherwise, invalid values stop startup when using `file`,
|
|
199
201
|
`s3`, or `gcs`.
|
|
200
202
|
These settings do not affect `none`, `memory`, or library callers.
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
|
-
import
|
|
2
|
+
import cluster from 'node:cluster';
|
|
3
|
+
import { availableParallelism } from 'node:os';
|
|
4
|
+
import { Command, Option, InvalidArgumentError } from 'commander';
|
|
3
5
|
import { initServer } from './server/index.js';
|
|
4
6
|
import * as caches from './cache/index.js';
|
|
5
7
|
import { setUserAgent } from './source/userAgent.js';
|
|
@@ -72,9 +74,12 @@ function parsePort(port) {
|
|
|
72
74
|
// undefined or invalid
|
|
73
75
|
return 3000;
|
|
74
76
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
function parseProcesses(value) {
|
|
78
|
+
const count = Number(value.trim() || NaN);
|
|
79
|
+
if (!Number.isSafeInteger(count) || count < 0) {
|
|
80
|
+
throw new InvalidArgumentError('processes must be a non-negative safe integer');
|
|
81
|
+
}
|
|
82
|
+
return count;
|
|
78
83
|
}
|
|
79
84
|
function parseDebug(debug) {
|
|
80
85
|
// command-line option
|
|
@@ -106,9 +111,23 @@ export function createProgram() {
|
|
|
106
111
|
.option('--gcs-api-endpoint <api-endpoint>', 'gcs api endpoint', '')
|
|
107
112
|
.option('-p, --port <port>', 'port number')
|
|
108
113
|
.option('--user-agent <user-agent>', 'User-Agent header for outbound HTTP requests')
|
|
109
|
-
.
|
|
114
|
+
.addOption(new Option('--prewarm [boolean]', 'startup renderer warmup')
|
|
115
|
+
.choices(['true', 'false']).preset('true').env('CHIITILER_PREWARM').default('true'))
|
|
116
|
+
.addOption(new Option('--processes <n>', 'worker processes (0 for all CPUs)')
|
|
117
|
+
.env('CHIITILER_PROCESSES').argParser(parseProcesses).default(1))
|
|
118
|
+
.addOption(new Option('--front-cache-ttl-sec <seconds>', 'memory front cache TTL (0 to disable)')
|
|
119
|
+
.env('CHIITILER_FRONT_CACHE_TTL_SEC'))
|
|
120
|
+
.addOption(new Option('--front-cache-max-bytes <bytes>', 'memory front cache byte limit (0 to disable)')
|
|
121
|
+
.env('CHIITILER_FRONT_CACHE_MAX_BYTES'))
|
|
110
122
|
.option('-D, --debug', 'debug mode')
|
|
111
123
|
.action(async (options) => {
|
|
124
|
+
const numProcesses = options.processes === 0 ? availableParallelism() : options.processes;
|
|
125
|
+
if (cluster.isPrimary && numProcesses !== 1) {
|
|
126
|
+
// Workers inherit argv and env, and initialize their own renderer and cache.
|
|
127
|
+
for (let i = 0; i < numProcesses; i++)
|
|
128
|
+
cluster.fork();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
112
131
|
// env fallback (CHIITILER_USER_AGENT) is handled in userAgent.ts
|
|
113
132
|
if (options.userAgent !== undefined)
|
|
114
133
|
setUserAgent(options.userAgent);
|
|
@@ -131,8 +150,8 @@ export function createProgram() {
|
|
|
131
150
|
debug: parseDebug(options.debug),
|
|
132
151
|
};
|
|
133
152
|
if (['file', 's3', 'gcs'].includes(serverOptions.cache.name)) {
|
|
134
|
-
const ttl =
|
|
135
|
-
const size =
|
|
153
|
+
const ttl = options.frontCacheTtlSec;
|
|
154
|
+
const size = options.frontCacheMaxBytes;
|
|
136
155
|
serverOptions.cache = caches.withMemoryCache(serverOptions.cache, {
|
|
137
156
|
ttlSeconds: ttl === undefined ? undefined : Number(ttl.trim() || NaN),
|
|
138
157
|
maxBytes: size === undefined ? undefined : Number(size.trim() || NaN),
|
|
@@ -147,7 +166,7 @@ export function createProgram() {
|
|
|
147
166
|
// warm up BEFORE listening: Lambda Web Adapter polls the
|
|
148
167
|
// readiness check until the port opens, so work done here
|
|
149
168
|
// stays inside the INIT phase (full CPU boost)
|
|
150
|
-
if (
|
|
169
|
+
if (options.prewarm === 'true') {
|
|
151
170
|
const startedAt = Date.now();
|
|
152
171
|
try {
|
|
153
172
|
await prewarm(serverOptions.cache);
|
package/dist/main.js
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
import cluster from 'node:cluster';
|
|
2
|
-
import { availableParallelism } from 'node:os';
|
|
3
1
|
import process from 'node:process';
|
|
4
2
|
import { createProgram } from './cli.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const processesEnv = Number(process.env.CHIITILER_PROCESSES);
|
|
10
|
-
if (processesEnv === 0)
|
|
11
|
-
return availableParallelism();
|
|
12
|
-
else
|
|
13
|
-
return processesEnv;
|
|
14
|
-
})();
|
|
15
|
-
if (cluster.isPrimary && numProcesses !== 1) {
|
|
16
|
-
// Fork workers.
|
|
17
|
-
for (let i = 0; i < numProcesses; i++)
|
|
18
|
-
cluster.fork();
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
program.parse(process.argv);
|
|
22
|
-
}
|
|
3
|
+
createProgram().parseAsync(process.argv).catch((error) => {
|
|
4
|
+
console.error(error);
|
|
5
|
+
process.exitCode = 1;
|
|
6
|
+
});
|