mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 13:39:01 +01:00 
			
		
		
		
	Fix healthcheck and some messages
This commit is contained in:
		
							parent
							
								
									02f218389b
								
							
						
					
					
						commit
						9a08aa2ab5
					
				@ -10,16 +10,25 @@ if (config.https) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const port = require('./src/services/port');
 | 
					const port = require('./src/services/port');
 | 
				
			||||||
const host = require('./src/services/host');
 | 
					const host = require('./src/services/host');
 | 
				
			||||||
const url = `http://${host}:${port}/api/health-check`;
 | 
					
 | 
				
			||||||
const options = { timeout: 2000 };
 | 
					let options = {timeout: 2000};
 | 
				
			||||||
const request = http.request(url, options, res => {
 | 
					const callback = res => {
 | 
				
			||||||
    console.log(`STATUS: ${res.statusCode}`);
 | 
					    console.log(`STATUS: ${res.statusCode}`);
 | 
				
			||||||
    if (res.statusCode === 200) {
 | 
					    if (res.statusCode === 200) {
 | 
				
			||||||
        process.exit(0);
 | 
					        process.exit(0);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        process.exit(1);
 | 
					        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 => {
 | 
					request.on("error", err => {
 | 
				
			||||||
    console.log("ERROR");
 | 
					    console.log("ERROR");
 | 
				
			||||||
    process.exit(1);
 | 
					    process.exit(1);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										13
									
								
								src/www
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								src/www
									
									
									
									
									
								
							@ -100,13 +100,14 @@ async function startTrilium() {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    httpServer.keepAliveTimeout = 120000 * 5;
 | 
					    httpServer.keepAliveTimeout = 120000 * 5;
 | 
				
			||||||
    if (port !== 0) {
 | 
					    const listenTcp = port !== 0;
 | 
				
			||||||
 | 
					    if (listenTcp) {
 | 
				
			||||||
      httpServer.listen(port, host); // TCP socket.
 | 
					      httpServer.listen(port, host); // TCP socket.
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      httpServer.listen(host); // Unix socket.
 | 
					      httpServer.listen(host); // Unix socket.
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    httpServer.on('error', error => {
 | 
					    httpServer.on('error', error => {
 | 
				
			||||||
            if (error.syscall !== 'listen') {
 | 
					            if (!listenTcp || error.syscall !== 'listen') {
 | 
				
			||||||
                throw error;
 | 
					                throw error;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -128,7 +129,13 @@ async function startTrilium() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    httpServer.on('listening', () => log.info(`Listening on port ${httpServer.address().port}`));
 | 
					    httpServer.on('listening', () => {
 | 
				
			||||||
 | 
					        if (listenTcp) {
 | 
				
			||||||
 | 
					            log.info(`Listening on port ${port}`)
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            log.info(`Listening on unix socket ${host}`)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ws.init(httpServer, sessionParser);
 | 
					    ws.init(httpServer, sessionParser);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user