Refactoring the debug mode code, and adding some options.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||
import type { ProsodyConfig } from './config'
|
||||
import { isDebugMode } from '../debug'
|
||||
import { debugNumericParameter } from '../debug'
|
||||
import { prosodyCtl, reloadProsody } from './ctl'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
@ -18,9 +18,8 @@ function startProsodyCertificatesRenewCheck (options: RegisterServerOptions, con
|
||||
return
|
||||
}
|
||||
|
||||
const debugMode = isDebugMode(options)
|
||||
// check every day (or every minutes in debug mode)
|
||||
const checkInterval = debugMode ? 60000 : 3600000 * 24
|
||||
const checkInterval = debugNumericParameter(options, 'renewCertCheckInterval', 60000, 3600000 * 24)
|
||||
|
||||
if (renew) {
|
||||
stopProsodyCertificatesRenewCheck(options)
|
||||
@ -91,8 +90,8 @@ async function renewCheckSelfSigned (options: RegisterServerOptions, config: Pro
|
||||
// We have to check if the self signed certificate is still valid.
|
||||
// Prosodyctl generated certificates are valid 365 days.
|
||||
// We will renew it every 10 months (and every X minutes in debug mode)
|
||||
const renewEvery = debugNumericParameter(options, 'renewSelfSignedCertInterval', 5 * 60000, 3600000 * 24 * 30 * 10)
|
||||
|
||||
const renewEvery = isDebugMode(options) ? 5 * 60000 : 3600000 * 24 * 30 * 10
|
||||
// getting the file date...
|
||||
const filepath = _filePathToTest(options, config)
|
||||
if (!filepath) { return }
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||
import type { ProsodyFilePaths } from './config/paths'
|
||||
import { isDebugMode } from '../debug'
|
||||
import { debugNumericParameter } from '../debug'
|
||||
import { reloadProsody } from './ctl'
|
||||
|
||||
type Rotate = (file: string, options: {
|
||||
@ -33,9 +33,10 @@ async function _rotate (options: RegisterServerOptions, path: string): Promise<v
|
||||
|
||||
function startProsodyLogRotate (options: RegisterServerOptions, paths: ProsodyFilePaths): void {
|
||||
const logger = options.peertubeHelpers.logger
|
||||
const debugMode = isDebugMode(options)
|
||||
const checkInterval = debugMode ? 60 * 1000 : 60 * 60 * 1000 // check every hour
|
||||
const rotateEvery = debugMode ? 2 * 60 * 1000 : 24 * 60 * 60 * 1000 // rotate every 24hour
|
||||
// check every hour
|
||||
const checkInterval = debugNumericParameter(options, 'logRotateCheckInterval', 60 * 1000, 60 * 60 * 1000)
|
||||
// rotate every 24hour
|
||||
const rotateEvery = debugNumericParameter(options, 'logRotateEvery', 2 * 60 * 1000, 24 * 60 * 60 * 1000)
|
||||
// TODO: also rotate when file is too big
|
||||
|
||||
if (logRotate) {
|
||||
|
Reference in New Issue
Block a user