[enh] better name for target in mails/logs
This commit is contained in:
@@ -33,7 +33,7 @@ export const mail = {
|
|||||||
|
|
||||||
onEstablished: (conf: Conf, target: string) => {
|
onEstablished: (conf: Conf, target: string) => {
|
||||||
return async () => {
|
return async () => {
|
||||||
console.log('Connection established')
|
console.log('Connection established for %s', target)
|
||||||
await sendMail(conf.mail, `[dwatcher] [${os.hostname}] Connection established`, `
|
await sendMail(conf.mail, `[dwatcher] [${os.hostname}] Connection established`, `
|
||||||
<p>
|
<p>
|
||||||
Connection from [${os.hostname}] to ${target} established on ${moment().format('DD-MM-YYYY HH:mm:ss')}.
|
Connection from [${os.hostname}] to ${target} established on ${moment().format('DD-MM-YYYY HH:mm:ss')}.
|
||||||
@@ -44,8 +44,8 @@ export const mail = {
|
|||||||
|
|
||||||
onDisconnect: (conf: Conf, target: string) => {
|
onDisconnect: (conf: Conf, target: string) => {
|
||||||
return async (waitingDelay: number) => {
|
return async (waitingDelay: number) => {
|
||||||
console.log('Connection closed')
|
console.log('Connection closed for %s', target)
|
||||||
console.log('Waiting %s seconds...', waitingDelay)
|
console.log('Waiting %s seconds...', (waitingDelay / 1000).toFixed(0))
|
||||||
await sendMail(conf.mail, `[dwatcher] [${os.hostname}] Connection closed`, `
|
await sendMail(conf.mail, `[dwatcher] [${os.hostname}] Connection closed`, `
|
||||||
<p>
|
<p>
|
||||||
Connection from [${os.hostname}] to ${target} was lost on ${moment().format('dd-MM-YYYY HH:mm:ss')}.
|
Connection from [${os.hostname}] to ${target} was lost on ${moment().format('dd-MM-YYYY HH:mm:ss')}.
|
||||||
@@ -59,7 +59,7 @@ export const mail = {
|
|||||||
|
|
||||||
onRestartSuccess: (conf: Conf, target: string) => {
|
onRestartSuccess: (conf: Conf, target: string) => {
|
||||||
return async () => {
|
return async () => {
|
||||||
console.log('Connection recovered')
|
console.log('Connection recovered for %s', target)
|
||||||
await sendMail(conf.mail, `[dwatcher] [${os.hostname}] Connection recovered`, `
|
await sendMail(conf.mail, `[dwatcher] [${os.hostname}] Connection recovered`, `
|
||||||
<p>
|
<p>
|
||||||
Connection from [${os.hostname}] to ${target} was recovered on ${moment().format('dd-MM-YYYY HH:mm:ss')}.
|
Connection from [${os.hostname}] to ${target} was recovered on ${moment().format('dd-MM-YYYY HH:mm:ss')}.
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export function ws2pWatcher(conf: Conf) {
|
|||||||
|
|
||||||
const keys = await Scrypt(wserver.salt, wserver.passwd)
|
const keys = await Scrypt(wserver.salt, wserver.passwd)
|
||||||
const keypair = new Key(keys.pub, keys.sec)
|
const keypair = new Key(keys.pub, keys.sec)
|
||||||
|
const target = `${wserver.address} (${wserver.expectedPubkey.substr(0, 8)})`
|
||||||
|
|
||||||
await watcherLoop(
|
await watcherLoop(
|
||||||
async () => {
|
async () => {
|
||||||
@@ -42,18 +43,18 @@ export function ws2pWatcher(conf: Conf) {
|
|||||||
|
|
||||||
conf.reconnectionDelays,
|
conf.reconnectionDelays,
|
||||||
|
|
||||||
mail.onEstablished(conf, wserver.expectedPubkey),
|
mail.onEstablished(conf, target),
|
||||||
|
|
||||||
// When a disconnection is detected
|
// When a disconnection is detected
|
||||||
mail.onDisconnect(conf, wserver.expectedPubkey),
|
mail.onDisconnect(conf, target),
|
||||||
|
|
||||||
async () => {
|
async () => {
|
||||||
console.log('Trying to connect to %s', wserver.expectedPubkey)
|
console.log('Trying to connect to %s', target)
|
||||||
},
|
},
|
||||||
|
|
||||||
mail.onRestartSuccess(conf, wserver.expectedPubkey),
|
mail.onRestartSuccess(conf, target),
|
||||||
|
|
||||||
mail.onError(conf, wserver.expectedPubkey)
|
mail.onError(conf, target)
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user