@@ -381,7 +381,10 @@ func startupCommand(ctx context.Context, inPgadmin *v1beta1.PGAdmin) []string {
381381 )
382382 var (
383383 maxBackupRetentionNumber = "1"
384- retentionPeriod = "24 * 60"
384+ // One day in minutes for pgadmin rotation
385+ pgAdminRetentionPeriod = "24 * 60"
386+ // Daily rotation for gunicorn rotation
387+ gunicornRetentionPeriod = "D"
385388 )
386389
387390 // If the OpenTelemetryLogs Feature is enabled and the user has set a retention period,
@@ -398,7 +401,10 @@ func startupCommand(ctx context.Context, inPgadmin *v1beta1.PGAdmin) []string {
398401 // for the currently-used log file.
399402 maxBackupRetentionNumber = strconv .Itoa (retentionNumber - 1 )
400403 if period == "hourly" {
401- retentionPeriod = "60"
404+ // If the period is hourly, set the pgadmin
405+ // and gunicorn retention periods to hourly.
406+ pgAdminRetentionPeriod = "60"
407+ gunicornRetentionPeriod = "H"
402408 }
403409 }
404410
@@ -420,7 +426,7 @@ if os.path.isfile('` + configDatabaseURIPathAbsolutePath + `'):
420426
421427DATA_DIR = '` + dataMountPath + `'
422428LOG_FILE = '` + LogFileAbsolutePath + `'
423- LOG_ROTATION_AGE = ` + retentionPeriod + ` # minutes
429+ LOG_ROTATION_AGE = ` + pgAdminRetentionPeriod + ` # minutes
424430LOG_ROTATION_SIZE = 5 # MiB
425431LOG_ROTATION_MAX_LOG_FILES = ` + maxBackupRetentionNumber + `
426432
@@ -455,9 +461,11 @@ logconfig_dict = copy.deepcopy(gunicorn.glogging.CONFIG_DEFAULTS)
455461logconfig_dict['loggers']['gunicorn.access']['handlers'] = ['file']
456462logconfig_dict['loggers']['gunicorn.error']['handlers'] = ['file']
457463logconfig_dict['handlers']['file'] = {
458- 'class': 'logging.handlers.RotatingFileHandler ',
464+ 'class': 'logging.handlers.TimedRotatingFileHandler ',
459465 'filename': '` + GunicornLogFileAbsolutePath + `',
460- 'backupCount': ` + maxBackupRetentionNumber + `, 'maxBytes': 2 << 20, # MiB
466+ 'backupCount': ` + maxBackupRetentionNumber + `,
467+ 'interval': 1, # every one unit (defined by when), rotate
468+ 'when': '` + gunicornRetentionPeriod + `',
461469 'formatter': 'json',
462470}
463471logconfig_dict['formatters']['json'] = {
0 commit comments