mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	server: Fix init database not working due to share db
This commit is contained in:
		| @@ -2,16 +2,21 @@ | |||||||
|  |  | ||||||
| import Database from "better-sqlite3"; | import Database from "better-sqlite3"; | ||||||
| import dataDir from "../services/data_dir.js"; | import dataDir from "../services/data_dir.js"; | ||||||
|  | import sql_init from "../services/sql_init.js"; | ||||||
|  |  | ||||||
| const dbConnection = new Database(dataDir.DOCUMENT_PATH, { readonly: true }); | let dbConnection!: Database.Database; | ||||||
|  |  | ||||||
| [`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `SIGTERM`].forEach(eventType => { | sql_init.dbReady.then(() => { | ||||||
|     process.on(eventType, () => { |     dbConnection = new Database(dataDir.DOCUMENT_PATH, { readonly: true }); | ||||||
|         if (dbConnection) { |      | ||||||
|             // closing connection is especially important to fold -wal file into the main DB file |     [`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `SIGTERM`].forEach(eventType => { | ||||||
|             // (see https://sqlite.org/tempfiles.html for details) |         process.on(eventType, () => { | ||||||
|             dbConnection.close(); |             if (dbConnection) { | ||||||
|         } |                 // closing connection is especially important to fold -wal file into the main DB file | ||||||
|  |                 // (see https://sqlite.org/tempfiles.html for details) | ||||||
|  |                 dbConnection.close(); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|     }); |     }); | ||||||
| }); | }); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user