mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-23 04:14:46 +02:00
Update proper lockfile settings #1326
This commit is contained in:
parent
2ae3ea346f
commit
f5009f76f4
2 changed files with 38 additions and 22 deletions
57
server/Db.js
57
server/Db.js
|
@ -27,17 +27,16 @@ class Db {
|
|||
this.SeriesPath = Path.join(global.ConfigPath, 'series')
|
||||
this.FeedsPath = Path.join(global.ConfigPath, 'feeds')
|
||||
|
||||
const staleTime = 1000 * 60 * 2
|
||||
this.libraryItemsDb = new njodb.Database(this.LibraryItemsPath, { lockoptions: { stale: staleTime } })
|
||||
this.usersDb = new njodb.Database(this.UsersPath, { lockoptions: { stale: staleTime } })
|
||||
this.sessionsDb = new njodb.Database(this.SessionsPath, { lockoptions: { stale: staleTime } })
|
||||
this.librariesDb = new njodb.Database(this.LibrariesPath, { datastores: 2, lockoptions: { stale: staleTime } })
|
||||
this.settingsDb = new njodb.Database(this.SettingsPath, { datastores: 2, lockoptions: { stale: staleTime } })
|
||||
this.collectionsDb = new njodb.Database(this.CollectionsPath, { datastores: 2, lockoptions: { stale: staleTime } })
|
||||
this.playlistsDb = new njodb.Database(this.PlaylistsPath, { datastores: 2, lockoptions: { stale: staleTime } })
|
||||
this.authorsDb = new njodb.Database(this.AuthorsPath, { lockoptions: { stale: staleTime } })
|
||||
this.seriesDb = new njodb.Database(this.SeriesPath, { datastores: 2, lockoptions: { stale: staleTime } })
|
||||
this.feedsDb = new njodb.Database(this.FeedsPath, { datastores: 2, lockoptions: { stale: staleTime } })
|
||||
this.libraryItemsDb = new njodb.Database(this.LibraryItemsPath, this.getNjodbOptions())
|
||||
this.usersDb = new njodb.Database(this.UsersPath, this.getNjodbOptions())
|
||||
this.sessionsDb = new njodb.Database(this.SessionsPath, this.getNjodbOptions())
|
||||
this.librariesDb = new njodb.Database(this.LibrariesPath, this.getNjodbOptions())
|
||||
this.settingsDb = new njodb.Database(this.SettingsPath, this.getNjodbOptions())
|
||||
this.collectionsDb = new njodb.Database(this.CollectionsPath, this.getNjodbOptions())
|
||||
this.playlistsDb = new njodb.Database(this.PlaylistsPath, this.getNjodbOptions())
|
||||
this.authorsDb = new njodb.Database(this.AuthorsPath, this.getNjodbOptions())
|
||||
this.seriesDb = new njodb.Database(this.SeriesPath, this.getNjodbOptions())
|
||||
this.feedsDb = new njodb.Database(this.FeedsPath, this.getNjodbOptions())
|
||||
|
||||
this.libraryItems = []
|
||||
this.users = []
|
||||
|
@ -59,6 +58,21 @@ class Db {
|
|||
return this.users.some(u => u.id === 'root')
|
||||
}
|
||||
|
||||
getNjodbOptions() {
|
||||
return {
|
||||
lockoptions: {
|
||||
stale: 1000 * 20, // 20 seconds
|
||||
update: 2500,
|
||||
retries: {
|
||||
retries: 20,
|
||||
minTimeout: 250,
|
||||
maxTimeout: 5000,
|
||||
factor: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getEntityDb(entityName) {
|
||||
if (entityName === 'user') return this.usersDb
|
||||
else if (entityName === 'session') return this.sessionsDb
|
||||
|
@ -88,17 +102,16 @@ class Db {
|
|||
}
|
||||
|
||||
reinit() {
|
||||
const staleTime = 1000 * 60 * 2
|
||||
this.libraryItemsDb = new njodb.Database(this.LibraryItemsPath, { lockoptions: { stale: staleTime } })
|
||||
this.usersDb = new njodb.Database(this.UsersPath, { lockoptions: { stale: staleTime } })
|
||||
this.sessionsDb = new njodb.Database(this.SessionsPath, { lockoptions: { stale: staleTime } })
|
||||
this.librariesDb = new njodb.Database(this.LibrariesPath, { datastores: 2, lockoptions: { stale: staleTime } })
|
||||
this.settingsDb = new njodb.Database(this.SettingsPath, { datastores: 2, lockoptions: { stale: staleTime } })
|
||||
this.collectionsDb = new njodb.Database(this.CollectionsPath, { datastores: 2, lockoptions: { stale: staleTime } })
|
||||
this.playlistsDb = new njodb.Database(this.PlaylistsPath, { datastores: 2, lockoptions: { stale: staleTime } })
|
||||
this.authorsDb = new njodb.Database(this.AuthorsPath, { lockoptions: { stale: staleTime } })
|
||||
this.seriesDb = new njodb.Database(this.SeriesPath, { datastores: 2, lockoptions: { stale: staleTime } })
|
||||
this.feedsDb = new njodb.Database(this.FeedsPath, { datastores: 2, lockoptions: { stale: staleTime } })
|
||||
this.libraryItemsDb = new njodb.Database(this.LibraryItemsPath, this.getNjodbOptions())
|
||||
this.usersDb = new njodb.Database(this.UsersPath, this.getNjodbOptions())
|
||||
this.sessionsDb = new njodb.Database(this.SessionsPath, this.getNjodbOptions())
|
||||
this.librariesDb = new njodb.Database(this.LibrariesPath, this.getNjodbOptions())
|
||||
this.settingsDb = new njodb.Database(this.SettingsPath, this.getNjodbOptions())
|
||||
this.collectionsDb = new njodb.Database(this.CollectionsPath, this.getNjodbOptions())
|
||||
this.playlistsDb = new njodb.Database(this.PlaylistsPath, this.getNjodbOptions())
|
||||
this.authorsDb = new njodb.Database(this.AuthorsPath, this.getNjodbOptions())
|
||||
this.seriesDb = new njodb.Database(this.SeriesPath, this.getNjodbOptions())
|
||||
this.feedsDb = new njodb.Database(this.FeedsPath, this.getNjodbOptions())
|
||||
return this.init()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue