1 Star 0 Fork 25

lanfeng1314/trilium

forked from Gitee 极速下载/trilium 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
docker_healthcheck.js 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
viperdc 提交于 2023-07-06 19:02 . Update docker_healthcheck.js
const http = require("http");
const ini = require("ini");
const fs = require("fs");
const dataDir = require("./src/services/data_dir");
const config = ini.parse(fs.readFileSync(dataDir.CONFIG_INI_PATH, 'utf-8'));
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);
}
const port = require('./src/services/port');
const host = require('./src/services/host');
const options = { timeout: 2000 };
const callback = 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();
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/lanfeng1314/trilium.git
git@gitee.com:lanfeng1314/trilium.git
lanfeng1314
trilium
trilium
master

搜索帮助