mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-01-05 20:39:49 -06:00
chore(docker): reintroduce healthchecks
This commit is contained in:
@@ -24,4 +24,4 @@ FROM node:22.14.0-bullseye-slim
|
||||
# Configure container
|
||||
EXPOSE 8080
|
||||
CMD [ "sh", "./start-docker.sh" ]
|
||||
HEALTHCHECK --start-period=10s CMD exec gosu node node docker_healthcheck.js
|
||||
HEALTHCHECK --start-period=10s CMD exec gosu node node /usr/src/app/docker_healthcheck.js
|
||||
@@ -22,4 +22,4 @@ FROM node:22.14.0-alpine
|
||||
# Configure container
|
||||
EXPOSE 8080
|
||||
CMD [ "sh", "./start-docker.sh" ]
|
||||
HEALTHCHECK --start-period=10s CMD exec su-exec node node docker_healthcheck.js
|
||||
HEALTHCHECK --start-period=10s CMD exec su-exec node node /usr/src/app/docker_healthcheck.js
|
||||
41
apps/server/src/docker_healthcheck.ts
Normal file
41
apps/server/src/docker_healthcheck.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import http from "http";
|
||||
import config from "./services/config.js";
|
||||
|
||||
if (config.Network.https) {
|
||||
// built-in TLS (terminated by trilium) is not supported yet, PRs are welcome
|
||||
// for reverse proxy terminated TLS this will works since config.https will be false
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
import port from "./services/port.js";
|
||||
import host from "./services/host.js";
|
||||
|
||||
const options: http.RequestOptions = { timeout: 2000 };
|
||||
|
||||
const callback: (res: http.IncomingMessage) => void = (res) => {
|
||||
console.log(`STATUS: ${res.statusCode}`);
|
||||
if (res.statusCode === 200) {
|
||||
process.exit(0);
|
||||
} else {
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
let request;
|
||||
|
||||
if (port !== 0) {
|
||||
// TCP socket.
|
||||
const url = `http://${host}:${port}/api/health-check`;
|
||||
request = http.request(url, options, callback);
|
||||
} else {
|
||||
// Unix socket.
|
||||
options.socketPath = host;
|
||||
options.path = "/api/health-check";
|
||||
request = http.request(options, callback);
|
||||
}
|
||||
|
||||
request.on("error", (err) => {
|
||||
console.log("ERROR");
|
||||
process.exit(1);
|
||||
});
|
||||
request.end();
|
||||
@@ -58,6 +58,9 @@ module.exports = {
|
||||
optimization: false,
|
||||
outputHashing: 'none',
|
||||
generatePackageJson: true,
|
||||
additionalEntryPoints: [
|
||||
"./src/docker_healthcheck.ts"
|
||||
],
|
||||
externalDependencies: [
|
||||
"electron/main",
|
||||
"@electron/remote/main",
|
||||
|
||||
Reference in New Issue
Block a user