Conversation
|
Hi @zstadler, IMHO it would be nice that That being said, why not using something like: HEALTHCHECK CMD curl --fail http://localhost:80/health || exit 1? HTH, |
|
The healthcheck responses are in the code since #140, about 6 years ago. IMHO, changing them would be more of an issue. I assume that |
|
Yes, there is a healthcheck endpoint for 6 years now. Commit 5d93b1d closed #140 by adding the endpoint. The code is there. The JS code in this PR serves as a replacement for |
|
Hello Everyone,
@zstadler I agree w/ you, just wondering if we want someday to add something more detailed to be used for readiness and liveness (and startup) K8s probes too. Docker Engine does nothing with those fine probes.
@zstadler That's fine and super sensitive 💪 to avoid adding binaries in the current image: 👍.
@acalcutt yes, it's the way it works, https://docs.docker.com/engine/reference/builder/#healthcheck:
HTH, |
@scara, |
|
Hi @zstadler,
This PR should land for those running the official image on Docker Engines: it does what it should does w/o adding extra binaries ( HTH, |
|
Are the changes in .gitattributes needed for this PR? while it looks like a good idea, I'm not sure it goes with this and should be done in a separate PR unless it is needed. Other than that I am likely to approve this, as long as my local testing works and there are no objections to it. I think allowing docker to use this built in health feature is a good idea. |
| var url = "http://localhost:80/health"; | ||
| var request = http.request(url, options, (res) => { | ||
| console.log(`STATUS: ${res.statusCode}`); | ||
| if (res.statusCode == 200) { |
There was a problem hiding this comment.
| if (res.statusCode == 200) { | |
| if (res.statusCode === 200) { |
There was a problem hiding this comment.
The type of the response StatusCode is a number. IMO, === is not needed for comparing that number with 200.
I've created #637 as a separate PR for |
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"
|
I tested this and looked at the healthcheck status with docker inspect and it was getting this error. I changed the require to an import in healthcheck.js to fix this, and now it is successful
|
Fixes #635