Prosody log rotation every 24 hour.

This commit is contained in:
John Livingston
2021-05-12 14:59:52 +02:00
parent c5bcf611d3
commit 4cf9ab51aa
6 changed files with 115 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import { getProsodyConfig, getProsodyFilePaths, writeProsodyConfig } from './config'
import { startProsodyLogRotate, stopProsodyLogRotate } from './logrotate'
import { changeHttpBindRoute } from '../routers/webchat'
import * as fs from 'fs'
import * as child_process from 'child_process'
@ -58,6 +59,15 @@ async function getProsodyAbout (options: RegisterServerOptions): Promise<string>
return ctl.message
}
async function reloadProsody (options: RegisterServerOptions): Promise<boolean> {
const reload = await prosodyCtl(options, 'reload')
if (reload.code) {
options.peertubeHelpers.logger.error('reloadProsody failed: ' + JSON.stringify(reload))
return false
}
return true
}
interface ProsodyRunning {
ok: boolean
messages: string[]
@ -208,9 +218,10 @@ async function ensureProsodyRunning (options: RegisterServerOptions): Promise<vo
}
if (!processStarted) {
logger.error('It seems that the Prosody process is not up')
} else {
logger.info('Prosody is running')
return
}
logger.info('Prosody is running')
startProsodyLogRotate(options, filePaths, reloadProsody)
}
async function ensureProsodyNotRunning (options: RegisterServerOptions): Promise<void> {
@ -218,6 +229,8 @@ async function ensureProsodyNotRunning (options: RegisterServerOptions): Promise
const logger = peertubeHelpers.logger
logger.info('Checking if Prosody is running, and shutting it down if so')
stopProsodyLogRotate(options)
// NB: this function is called on plugin unregister, even if prosody is not used
// so we must avoid creating the working dir now
const filePaths = await getProsodyFilePaths(options)