WIP
This commit is contained in:
@@ -5,12 +5,14 @@ import {ws2pWatcher} from "./watchers/ws2p/ws2p-watcher";
|
||||
import {bmaWatcher} from "./watchers/bma/bma-watcher";
|
||||
import {dprobeHeartbeat} from './watchers/dprobe/dprobe-heartbeat-watcher'
|
||||
import {webDiffWatcher} from "./watchers/webdiff/webdiff-watcher";
|
||||
import {ServiceState} from "./types/state";
|
||||
|
||||
export async function dwatch(confFile: string) {
|
||||
|
||||
const yml = fs.readFileSync(confFile, 'utf8')
|
||||
const conf = yaml.load(yml) as Conf
|
||||
|
||||
const states: ServiceState[] = []
|
||||
const watchers: () => Promise<>
|
||||
await Promise.all((conf.ws2pServers || []).map(ws2pWatcher(conf)))
|
||||
await Promise.all((conf.bmaServers || []).map(bmaWatcher(conf)))
|
||||
await Promise.all((conf.dprobeHeartbeats || []).map(dprobeHeartbeat(conf)))
|
||||
|
||||
3
src/lib/types/state.ts
Normal file
3
src/lib/types/state.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface ServiceState {
|
||||
state: 'INIT'|'OK'|'FAILURE'
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
export async function watcherLoop(
|
||||
import {ServiceState} from "./types/state";
|
||||
|
||||
export function watcherLoop(
|
||||
connect: () => Promise<void>,
|
||||
onConnectionClosed: () => Promise<void>,
|
||||
reconnectionDelays: number[],
|
||||
@@ -7,8 +9,9 @@ export async function watcherLoop(
|
||||
onRestart: () => Promise<void>,
|
||||
onRestartSuccess: () => Promise<void>,
|
||||
onError: (e: Error) => Promise<void>,
|
||||
) {
|
||||
): ServiceState {
|
||||
|
||||
let state: ServiceState = { state: 'INIT' }
|
||||
let hasStarted = false
|
||||
|
||||
;(async () => {
|
||||
|
||||
Reference in New Issue
Block a user