mirror of
https://github.com/maptiler/tileserver-gl.git
synced 2024-11-28 05:13:04 +03:00
Add Docker Healthcheck (#636)
* Add Docker Healthcheck Fixes #635 * Update Dockerfile_light * Update healthcheck.js fix healthcheck output error: "file:///usr/src/app/src/healthcheck.js:1\nvar http = require(\"http\");\n ^\n\nReferenceError: require is not defined in ES module scope, you can use import instead\nThis file is being treated as an ES module because it has a '.js' file extension and '/usr/src/app/package.json' contains \"type\": \"module\". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.\n at file:///usr/src/app/src/healthcheck.js:1:12\n at ModuleJob.run (node:internal/modules/esm/module_job:193:25)\n at async Promise.all (index 0)\n at async ESMLoader.import (node:internal/modules/esm/loader:526:24)\n at async loadESM (node:internal/process/esm_loader:91:5)\n at async handleMainPromise (node:internal/modules/run_main:65:12)\n" * update version Co-authored-by: acalcutt <acalcutt@techidiots.net>
This commit is contained in:
parent
d97c217e62
commit
50201f0a99
@ -81,3 +81,5 @@ EXPOSE 80
|
||||
USER node:node
|
||||
|
||||
ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"]
|
||||
|
||||
HEALTHCHECK CMD node /usr/src/app/src/healthcheck.js
|
||||
|
@ -32,3 +32,4 @@ COPY / /usr/src/app
|
||||
RUN cd /usr/src/app && npm install --omit=dev
|
||||
RUN ["chmod", "+x", "/usr/src/app/docker-entrypoint.sh"]
|
||||
USER node:node
|
||||
HEALTHCHECK CMD node /usr/src/app/src/healthcheck.js
|
||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "tileserver-gl",
|
||||
"version": "4.1.2",
|
||||
"version": "4.1.3",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "tileserver-gl",
|
||||
"version": "4.1.2",
|
||||
"version": "4.1.3",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"@mapbox/glyph-pbf-composite": "0.0.3",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tileserver-gl",
|
||||
"version": "4.1.2",
|
||||
"version": "4.1.3",
|
||||
"description": "Map tile server for JSON GL styles - vector and server side generated raster tiles",
|
||||
"main": "src/main.js",
|
||||
"bin": "src/main.js",
|
||||
|
18
src/healthcheck.js
Normal file
18
src/healthcheck.js
Normal file
@ -0,0 +1,18 @@
|
||||
import * as http from 'http';
|
||||
var options = {
|
||||
timeout: 2000,
|
||||
};
|
||||
var url = "http://localhost:80/health";
|
||||
var request = http.request(url, options, (res) => {
|
||||
console.log(`STATUS: ${res.statusCode}`);
|
||||
if (res.statusCode == 200) {
|
||||
process.exit(0);
|
||||
} else {
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
request.on("error", function (err) {
|
||||
console.log("ERROR");
|
||||
process.exit(1);
|
||||
});
|
||||
request.end();
|
Loading…
Reference in New Issue
Block a user