mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	server: Fix init database not working due to share db
This commit is contained in:
		
							parent
							
								
									10239d1a0b
								
							
						
					
					
						commit
						c20c8d1176
					
				| @ -2,10 +2,14 @@ | |||||||
| 
 | 
 | ||||||
| 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(() => { | ||||||
|  |     dbConnection = new Database(dataDir.DOCUMENT_PATH, { readonly: true }); | ||||||
|  |      | ||||||
|  |     [`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `SIGTERM`].forEach(eventType => { | ||||||
|         process.on(eventType, () => { |         process.on(eventType, () => { | ||||||
|             if (dbConnection) { |             if (dbConnection) { | ||||||
|                 // closing connection is especially important to fold -wal file into the main DB file
 |                 // closing connection is especially important to fold -wal file into the main DB file
 | ||||||
| @ -13,6 +17,7 @@ const dbConnection = new Database(dataDir.DOCUMENT_PATH, { readonly: true }); | |||||||
|                 dbConnection.close(); |                 dbConnection.close(); | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|  |     }); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| function getRawRows<T>(query: string, params = []): T[] { | function getRawRows<T>(query: string, params = []): T[] { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran