mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	
		
			
	
	
		
			27 lines
		
	
	
		
			786 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
		
		
			
		
	
	
			27 lines
		
	
	
		
			786 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 
								 | 
							
								const http = require("http");
							 | 
						||
| 
								 | 
							
								const config = require("./src/services/config");
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								if (config.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);
							 | 
						||
| 
								 | 
							
								    return;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								const port = require('./src/services/port');
							 | 
						||
| 
								 | 
							
								const host = require('./src/services/host');
							 | 
						||
| 
								 | 
							
								const url = `http://${host}:${port}/api/health-check`;
							 | 
						||
| 
								 | 
							
								const options = { timeout: 2000 };
							 | 
						||
| 
								 | 
							
								const 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", err => {
							 | 
						||
| 
								 | 
							
								    console.log("ERROR");
							 | 
						||
| 
								 | 
							
								    process.exit(1);
							 | 
						||
| 
								 | 
							
								});
							 | 
						||
| 
								 | 
							
								request.end();
							 |