New debug mode:
Debug mode is no more triggered by the NODE_ENV value, but by testing the existance of a file in the plugin data directory.
This commit is contained in:
parent
f8b83defb5
commit
b4dabfeeb9
@ -9,6 +9,7 @@
|
|||||||
### Minor changes and fixes
|
### Minor changes and fixes
|
||||||
|
|
||||||
* Diagnostic tool: add the result of `prosodyctl check` in the debug section.
|
* Diagnostic tool: add the result of `prosodyctl check` in the debug section.
|
||||||
|
* New debug mode
|
||||||
|
|
||||||
## 6.2.3
|
## 6.2.3
|
||||||
|
|
||||||
|
19
server/lib/debug.ts
Normal file
19
server/lib/debug.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
|
import * as path from 'path'
|
||||||
|
import * as fs from 'fs'
|
||||||
|
|
||||||
|
export function isDebugMode (options: RegisterServerOptions): boolean {
|
||||||
|
const peertubeHelpers = options.peertubeHelpers
|
||||||
|
const logger = peertubeHelpers.logger
|
||||||
|
|
||||||
|
if (!peertubeHelpers.plugin) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const filepath = path.resolve(peertubeHelpers.plugin.getDataDirectoryPath(), 'debug_mode')
|
||||||
|
logger.debug('Testing debug mode by testing if file exists: ' + filepath)
|
||||||
|
if (fs.existsSync(filepath)) {
|
||||||
|
logger.info('Plugin livechat Debug mode is on.')
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
@ -5,6 +5,6 @@ export async function diagBackend (test: string, _options: RegisterServerOptions
|
|||||||
const result = newResult(test)
|
const result = newResult(test)
|
||||||
result.label = 'Backend connection'
|
result.label = 'Backend connection'
|
||||||
result.ok = true
|
result.ok = true
|
||||||
result.next = 'webchat-video'
|
result.next = 'debug'
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
12
server/lib/diagnostic/debug.ts
Normal file
12
server/lib/diagnostic/debug.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
|
import { newResult, TestResult } from './utils'
|
||||||
|
import { isDebugMode } from '../../lib/debug'
|
||||||
|
|
||||||
|
export async function diagDebug (test: string, options: RegisterServerOptions): Promise<TestResult> {
|
||||||
|
const result = newResult(test)
|
||||||
|
result.label = 'Test debug mode'
|
||||||
|
result.ok = true
|
||||||
|
result.messages = [isDebugMode(options) ? 'Debug mode is ON' : 'Debug mode is OFF']
|
||||||
|
result.next = 'webchat-video'
|
||||||
|
return result
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import { diagBackend } from './backend'
|
import { diagBackend } from './backend'
|
||||||
import { TestResult, newResult } from './utils'
|
import { TestResult, newResult } from './utils'
|
||||||
|
import { diagDebug } from './debug'
|
||||||
import { diagProsody } from './prosody'
|
import { diagProsody } from './prosody'
|
||||||
import { diagVideo } from './video'
|
import { diagVideo } from './video'
|
||||||
|
|
||||||
@ -9,6 +10,8 @@ export async function diag (test: string, options: RegisterServerOptions): Promi
|
|||||||
|
|
||||||
if (test === 'backend') {
|
if (test === 'backend') {
|
||||||
result = await diagBackend(test, options)
|
result = await diagBackend(test, options)
|
||||||
|
} else if (test === 'debug') {
|
||||||
|
result = await diagDebug(test, options)
|
||||||
} else if (test === 'webchat-video') {
|
} else if (test === 'webchat-video') {
|
||||||
result = await diagVideo(test, options)
|
result = await diagVideo(test, options)
|
||||||
} else if (test === 'prosody') {
|
} else if (test === 'prosody') {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
type nextValue = 'backend' | 'webchat-video' | 'prosody'
|
type nextValue = 'backend' | 'debug' | 'webchat-video' | 'prosody'
|
||||||
|
|
||||||
interface MessageWithLevel {
|
interface MessageWithLevel {
|
||||||
level: 'info' | 'warning' | 'error'
|
level: 'info' | 'warning' | 'error'
|
||||||
|
@ -347,7 +347,7 @@ async function ensureProsodyRunning (options: RegisterServerOptions): Promise<vo
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
logger.info('Prosody is running')
|
logger.info('Prosody is running')
|
||||||
startProsodyLogRotate(options, filePaths, reloadProsody)
|
await startProsodyLogRotate(options, filePaths, reloadProsody)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ensureProsodyNotRunning (options: RegisterServerOptions): Promise<void> {
|
async function ensureProsodyNotRunning (options: RegisterServerOptions): Promise<void> {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import type { ProsodyFilePaths } from './config/paths'
|
import type { ProsodyFilePaths } from './config/paths'
|
||||||
|
import { isDebugMode } from '../debug'
|
||||||
|
|
||||||
type Rotate = (file: string, options: {
|
type Rotate = (file: string, options: {
|
||||||
count?: number
|
count?: number
|
||||||
@ -32,8 +33,9 @@ async function _rotate (options: RegisterServerOptions, path: string): Promise<v
|
|||||||
|
|
||||||
function startProsodyLogRotate (options: RegisterServerOptions, paths: ProsodyFilePaths, reload: ReloadProsody): void {
|
function startProsodyLogRotate (options: RegisterServerOptions, paths: ProsodyFilePaths, reload: ReloadProsody): void {
|
||||||
const logger = options.peertubeHelpers.logger
|
const logger = options.peertubeHelpers.logger
|
||||||
const checkInterval = process.env.NODE_ENV === 'test' ? 60 * 1000 : 60 * 60 * 1000 // check every hour
|
const debugMode = isDebugMode(options)
|
||||||
const rotateEvery = process.env.NODE_ENV === 'test' ? 2 * 60 * 1000 : 24 * 60 * 60 * 1000 // rotate every 24hour
|
const checkInterval = debugMode ? 60 * 1000 : 60 * 60 * 1000 // check every hour
|
||||||
|
const rotateEvery = debugMode ? 2 * 60 * 1000 : 24 * 60 * 60 * 1000 // rotate every 24hour
|
||||||
// TODO: also rotate when file is too big
|
// TODO: also rotate when file is too big
|
||||||
|
|
||||||
if (logRotate) {
|
if (logRotate) {
|
||||||
|
@ -64,3 +64,16 @@ ESBuild kann mit Typescript umgehen, prüft aber keine Typen
|
|||||||
(siehe [ESBuild-Dokumentation](https://esbuild.github.io/content-types/#typescript)).
|
(siehe [ESBuild-Dokumentation](https://esbuild.github.io/content-types/#typescript)).
|
||||||
Deshalb kompilieren wir Typescript zuerst mit der Option `-noEmit`, nur um die Typen zu überprüfen (`check:client:ts` in der package.json Datei).
|
Deshalb kompilieren wir Typescript zuerst mit der Option `-noEmit`, nur um die Typen zu überprüfen (`check:client:ts` in der package.json Datei).
|
||||||
Dann, wenn alles in Ordnung ist, führen wir ESBuild aus, um das kompilierte Javascript zu erzeugen.
|
Dann, wenn alles in Ordnung ist, führen wir ESBuild aus, um das kompilierte Javascript zu erzeugen.
|
||||||
|
|
||||||
|
## Debug Mode
|
||||||
|
|
||||||
|
There is a debug mode for this plugin, that shorten some delay.
|
||||||
|
For example, some log files will rotate every two minutes, instead of once per day.
|
||||||
|
This permit to test more easily certain actions, for which it could normally take hours or days to wait.
|
||||||
|
|
||||||
|
To enable this mode, you juste have to create the
|
||||||
|
`/var/www/peertube/storage/plugins/data/peertube-plugin-livechat/debug_mode` file
|
||||||
|
(replacing `/var/www/peertube/storage/` by the correct path on your installation).
|
||||||
|
|
||||||
|
The simple existence of this file is sufficient to trigger the debug mode.
|
||||||
|
To make sure it's taken into account, you can restart your Peertube instance.
|
||||||
|
@ -66,3 +66,16 @@ ESBuild can handle Typescript, but does not check types
|
|||||||
(see [ESBuild documentation](https://esbuild.github.io/content-types/#typescript)).
|
(see [ESBuild documentation](https://esbuild.github.io/content-types/#typescript)).
|
||||||
That's why we first compile Typescript with the `-noEmit` option, just to check types (`check:client:ts` in package.json file).
|
That's why we first compile Typescript with the `-noEmit` option, just to check types (`check:client:ts` in package.json file).
|
||||||
Then, if everything is okay, we run ESBuild to generate the compiled javascript.
|
Then, if everything is okay, we run ESBuild to generate the compiled javascript.
|
||||||
|
|
||||||
|
## Debug Mode
|
||||||
|
|
||||||
|
There is a debug mode for this plugin, that shorten some delay.
|
||||||
|
For example, some log files will rotate every two minutes, instead of once per day.
|
||||||
|
This permit to test more easily certain actions, for which it could normally take hours or days to wait.
|
||||||
|
|
||||||
|
To enable this mode, you juste have to create the
|
||||||
|
`/var/www/peertube/storage/plugins/data/peertube-plugin-livechat/debug_mode` file
|
||||||
|
(replacing `/var/www/peertube/storage/` by the correct path on your installation).
|
||||||
|
|
||||||
|
The simple existence of this file is sufficient to trigger the debug mode.
|
||||||
|
To make sure it's taken into account, you can restart your Peertube instance.
|
||||||
|
@ -64,3 +64,17 @@ ESBuild peut gérer Typescript, mais ne vérifie pas les types
|
|||||||
(voir [la documentation ESBuild](https://esbuild.github.io/content-types/#typescript)).
|
(voir [la documentation ESBuild](https://esbuild.github.io/content-types/#typescript)).
|
||||||
C'est pourquoi on compile d'abord Typescript avec l'option `-noEmit`, juste pour vérifier les types (`check:client:ts` dans le fichier package.json).
|
C'est pourquoi on compile d'abord Typescript avec l'option `-noEmit`, juste pour vérifier les types (`check:client:ts` dans le fichier package.json).
|
||||||
Ensuite, si tout est ok, on lance ESBuild pour générer le javascript compilé.
|
Ensuite, si tout est ok, on lance ESBuild pour générer le javascript compilé.
|
||||||
|
|
||||||
|
## Debug Mode
|
||||||
|
|
||||||
|
Il existe un mode de debug pour le plugin, qui va raccourcir le délais de certaines actions.
|
||||||
|
Par exemple, il va faire tourner les journaux toutes les deux minutes, au lieu de tous les jours.
|
||||||
|
Cela permet de tester plus facilement certaines actions, pour lesquelles il faudrait normalement attendre
|
||||||
|
des heures ou des jours.
|
||||||
|
|
||||||
|
Pour activer ce mode, il suffit de créer un fichier
|
||||||
|
`/var/www/peertube/storage/plugins/data/peertube-plugin-livechat/debug_mode`
|
||||||
|
(en adaptant `/var/www/peertube/storage/` à votre installation le cas échéant).
|
||||||
|
|
||||||
|
La simple existance de ce fichier suffit à déclencher le mode debug.
|
||||||
|
Pour être sûr qu'il est pris en compte, vous pouvez redémarrer votre instance Peertube.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user