mirror of
https://github.com/chrisbenincasa/tunarr.git
synced 2026-04-18 09:03:35 -04:00
fix: prevent "sonic boom is not ready yet" errors on system settings change
This commit is contained in:
@@ -196,10 +196,6 @@ export const systemApiRouter: RouterPluginAsyncCallback = async (
|
||||
return file;
|
||||
});
|
||||
|
||||
if (req.body.logging?.logRollConfig) {
|
||||
LoggerFactory.rollLogsNow();
|
||||
}
|
||||
|
||||
const refreshedSettings = req.serverCtx.settings.systemSettings();
|
||||
|
||||
return res.send(getSystemSettingsResponse(refreshedSettings));
|
||||
|
||||
@@ -133,6 +133,9 @@ class LoggerFactoryImpl {
|
||||
!isEqual(prevSettings.system.logging.logRollConfig, currentSettings)
|
||||
) {
|
||||
this.updateLevel(newLevel);
|
||||
setTimeout(() => {
|
||||
this.rollLogsNow();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ export class RollingLogDestination {
|
||||
private currentFileName: string;
|
||||
private createdFileNames: string[] = [];
|
||||
private rotatePattern: RegExp;
|
||||
private destinationReady = false;
|
||||
|
||||
constructor(private opts: Opts) {
|
||||
this.rotatePattern = new RegExp(`(\\d+)${this.opts.extension ?? ''}$`);
|
||||
@@ -76,6 +77,10 @@ export class RollingLogDestination {
|
||||
dest: this.opts.fileName,
|
||||
});
|
||||
|
||||
this.destination.once('ready', () => {
|
||||
this.destinationReady = true;
|
||||
});
|
||||
|
||||
if (this.opts.maxSizeBytes && this.opts.maxSizeBytes > 0) {
|
||||
let currentSize = getFileSize(this.currentFileName);
|
||||
this.destination.on('write', (size) => {
|
||||
@@ -111,12 +116,18 @@ export class RollingLogDestination {
|
||||
return;
|
||||
}
|
||||
|
||||
this.destinationReady = false;
|
||||
this.destination.end();
|
||||
|
||||
this.scheduledTask?.cancel(false);
|
||||
}
|
||||
|
||||
roll() {
|
||||
if (!this.destination) {
|
||||
return;
|
||||
} else if (!this.destinationReady) {
|
||||
this.destination.once('ready', () => this.roll());
|
||||
return;
|
||||
}
|
||||
|
||||
this.destination.flushSync();
|
||||
|
||||
Reference in New Issue
Block a user