mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-18 21:54:09 +00:00
detect EADDRINUSE on server start (#1348)
* detect `EADDRINUSE` on server start * @ts-expect-error * send portError to electron * use escalateErrorFn * dont move in docker * allow errors to be sendt to electron UI * Log after the new port is found * Update comment Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com> * update comment Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com> * update comment Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com> * rename to escalate * extract `serverTryDesiredPort` * type check server.address() * request shutdown on `unrecoverable` `escalateError` * combine network utils * reject promise * not unrecoverable by default * unneeded assignment --------- Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
1af394cd49
commit
29243e3f6c
@@ -8,7 +8,7 @@ import { isProduction } from '../externals.js';
|
||||
|
||||
class Logger {
|
||||
private queue: Log[];
|
||||
private escalateErrorFn: ((error: string) => void) | null;
|
||||
private escalateErrorFn: ((error: string, unrecoverable: boolean) => void) | null;
|
||||
private canLog = false;
|
||||
|
||||
constructor() {
|
||||
@@ -20,7 +20,7 @@ class Logger {
|
||||
/**
|
||||
* Enabling setup logger after init
|
||||
*/
|
||||
init(escalateErrorFn?: (error: string) => void) {
|
||||
init(escalateErrorFn?: (error: string, unrecoverable: boolean) => void) {
|
||||
// flush logs from queue
|
||||
this.queue.forEach((log) => {
|
||||
this._push(log);
|
||||
@@ -103,8 +103,11 @@ class Logger {
|
||||
* @param origin
|
||||
* @param text
|
||||
*/
|
||||
error(origin: string, text: string) {
|
||||
error(origin: string, text: string, escalate = false) {
|
||||
this.emit(LogLevel.Error, origin, text);
|
||||
if (escalate) {
|
||||
this.escalateErrorFn?.(text, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +117,7 @@ class Logger {
|
||||
*/
|
||||
crash(origin: string, text: string) {
|
||||
this.emit(LogLevel.Severe, origin, text);
|
||||
this.escalateErrorFn?.(text);
|
||||
this.escalateErrorFn?.(text, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user