WIP
This commit is contained in:
79
app.yml
79
app.yml
@@ -1,4 +1,39 @@
|
|||||||
connectionTimeout: 10000
|
connectionTimeout: 10000
|
||||||
|
ws2pServers:
|
||||||
|
- address: ws://g1-test.cgeek.fr:22001
|
||||||
|
expectedPubkey: 3dnbnYY9i2bHMQUGyFp5GVvJ2wBkVpus31cDJA5cfRpj
|
||||||
|
salt: test
|
||||||
|
passwd: test
|
||||||
|
currency: g1-test # Ensure we connect to the correct currency
|
||||||
|
|
||||||
|
bmaServers:
|
||||||
|
- address: https://g1-test.cgeek.fr
|
||||||
|
frequency: 60000 # 1'
|
||||||
|
# - address: http://remuniter.cgeek.fr:16120
|
||||||
|
# frequency: 60000 # 1'
|
||||||
|
# maxLate: 14400000 # 4h'
|
||||||
|
|
||||||
|
dprobeHeartbeats:
|
||||||
|
# - address: https://wotwizard.cgeek.fr/dprobe.heartbeat.txt
|
||||||
|
# frequency: 60000 # 1'
|
||||||
|
# lastBeat: 300000 # 5'
|
||||||
|
|
||||||
|
webDiffServers:
|
||||||
|
# - file1: https://wotwizard.cgeek.fr/WWMeta.json
|
||||||
|
# file2: https://wotwizard2.cgeek.fr/WWMeta.json
|
||||||
|
# frequency: 60000
|
||||||
|
|
||||||
|
mail:
|
||||||
|
enabled: false
|
||||||
|
host: smtp.sparkpostmail.com
|
||||||
|
port: 587
|
||||||
|
auth: LOGIN
|
||||||
|
encryption: STARTTLS
|
||||||
|
username: SMTP_Injection
|
||||||
|
apikey: 6976eb51635b680b832dbe4914524d2c038a13b6
|
||||||
|
from: '"DWatcher" <dwatcher@cgeek.fr>'
|
||||||
|
to: cem.moreau@gmail.com
|
||||||
|
|
||||||
reconnectionDelays:
|
reconnectionDelays:
|
||||||
- 5000
|
- 5000
|
||||||
- 10000
|
- 10000
|
||||||
@@ -26,46 +61,4 @@ reconnectionDelays:
|
|||||||
- 14400000 # 4h
|
- 14400000 # 4h
|
||||||
- 21600000 # 6h
|
- 21600000 # 6h
|
||||||
- 21600000 # 6h
|
- 21600000 # 6h
|
||||||
- 43200000 # 12h
|
- 43200000 # 12h
|
||||||
- 43200000 # 12h
|
|
||||||
- 43200000 # 12h
|
|
||||||
- 43200000 # 12h
|
|
||||||
- 43200000 # 12h
|
|
||||||
- 43200000 # 12h
|
|
||||||
- 43200000 # 12h
|
|
||||||
- 43200000 # 12h
|
|
||||||
- 43200000 # 12h
|
|
||||||
ws2pServers:
|
|
||||||
- address: ws://g1-test.cgeek.fr:22001
|
|
||||||
expectedPubkey: 3dnbnYY9i2bHMQUGyFp5GVvJ2wBkVpus31cDJA5cfRpj
|
|
||||||
salt: test
|
|
||||||
passwd: test
|
|
||||||
currency: g1-test # Ensure we connect to the correct currency
|
|
||||||
|
|
||||||
bmaServers:
|
|
||||||
- address: https://g1-test.cgeek.fr
|
|
||||||
frequency: 60000 # 1'
|
|
||||||
- address: http://remuniter.cgeek.fr:16120
|
|
||||||
frequency: 60000 # 1'
|
|
||||||
maxLate: 14400000 # 4h'
|
|
||||||
|
|
||||||
dprobeHeartbeats:
|
|
||||||
- address: https://wotwizard.cgeek.fr/dprobe.heartbeat.txt
|
|
||||||
frequency: 60000 # 1'
|
|
||||||
lastBeat: 300000 # 5'
|
|
||||||
|
|
||||||
webDiffServers:
|
|
||||||
- file1: https://wotwizard.cgeek.fr/WWMeta.json
|
|
||||||
file2: https://wotwizard2.cgeek.fr/WWMeta.json
|
|
||||||
frequency: 60000
|
|
||||||
|
|
||||||
mail:
|
|
||||||
enabled: false
|
|
||||||
host: smtp.sparkpostmail.com
|
|
||||||
port: 587
|
|
||||||
auth: LOGIN
|
|
||||||
encryption: STARTTLS
|
|
||||||
username: SMTP_Injection
|
|
||||||
apikey: 6976eb51635b680b832dbe4914524d2c038a13b6
|
|
||||||
from: '"DWatcher" <dwatcher@cgeek.fr>'
|
|
||||||
to: cem.moreau@gmail.com
|
|
||||||
@@ -5,12 +5,14 @@ import {ws2pWatcher} from "./watchers/ws2p/ws2p-watcher";
|
|||||||
import {bmaWatcher} from "./watchers/bma/bma-watcher";
|
import {bmaWatcher} from "./watchers/bma/bma-watcher";
|
||||||
import {dprobeHeartbeat} from './watchers/dprobe/dprobe-heartbeat-watcher'
|
import {dprobeHeartbeat} from './watchers/dprobe/dprobe-heartbeat-watcher'
|
||||||
import {webDiffWatcher} from "./watchers/webdiff/webdiff-watcher";
|
import {webDiffWatcher} from "./watchers/webdiff/webdiff-watcher";
|
||||||
|
import {ServiceState} from "./types/state";
|
||||||
|
|
||||||
export async function dwatch(confFile: string) {
|
export async function dwatch(confFile: string) {
|
||||||
|
|
||||||
const yml = fs.readFileSync(confFile, 'utf8')
|
const yml = fs.readFileSync(confFile, 'utf8')
|
||||||
const conf = yaml.load(yml) as Conf
|
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.ws2pServers || []).map(ws2pWatcher(conf)))
|
||||||
await Promise.all((conf.bmaServers || []).map(bmaWatcher(conf)))
|
await Promise.all((conf.bmaServers || []).map(bmaWatcher(conf)))
|
||||||
await Promise.all((conf.dprobeHeartbeats || []).map(dprobeHeartbeat(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>,
|
connect: () => Promise<void>,
|
||||||
onConnectionClosed: () => Promise<void>,
|
onConnectionClosed: () => Promise<void>,
|
||||||
reconnectionDelays: number[],
|
reconnectionDelays: number[],
|
||||||
@@ -7,8 +9,9 @@ export async function watcherLoop(
|
|||||||
onRestart: () => Promise<void>,
|
onRestart: () => Promise<void>,
|
||||||
onRestartSuccess: () => Promise<void>,
|
onRestartSuccess: () => Promise<void>,
|
||||||
onError: (e: Error) => Promise<void>,
|
onError: (e: Error) => Promise<void>,
|
||||||
) {
|
): ServiceState {
|
||||||
|
|
||||||
|
let state: ServiceState = { state: 'INIT' }
|
||||||
let hasStarted = false
|
let hasStarted = false
|
||||||
|
|
||||||
;(async () => {
|
;(async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user