[enh] hostname in mails
This commit is contained in:
@@ -2,6 +2,7 @@ import {moment} from "duniter/app/lib/common-libs/moment";
|
|||||||
import {Conf} from "./types/conf";
|
import {Conf} from "./types/conf";
|
||||||
import {ConfMail} from './types/conf'
|
import {ConfMail} from './types/conf'
|
||||||
import * as nodemailer from 'nodemailer'
|
import * as nodemailer from 'nodemailer'
|
||||||
|
import * as os from 'os'
|
||||||
|
|
||||||
export async function sendMail(conf: ConfMail, subject: string, html: string) {
|
export async function sendMail(conf: ConfMail, subject: string, html: string) {
|
||||||
|
|
||||||
@@ -33,7 +34,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')
|
||||||
await sendMail(conf.mail, '[dwatcher] Connection established', `
|
await sendMail(conf.mail, `[dwatcher] [${os.hostname}] Connection established`, `
|
||||||
<p>
|
<p>
|
||||||
Connection to ${target} established on ${moment().format('DD-MM-YYYY HH:mm:ss')}.
|
Connection to ${target} established on ${moment().format('DD-MM-YYYY HH:mm:ss')}.
|
||||||
</p>
|
</p>
|
||||||
@@ -45,7 +46,7 @@ export const mail = {
|
|||||||
return async (waitingDelay: number) => {
|
return async (waitingDelay: number) => {
|
||||||
console.log('Connection closed')
|
console.log('Connection closed')
|
||||||
console.log('Waiting %s seconds...', waitingDelay)
|
console.log('Waiting %s seconds...', waitingDelay)
|
||||||
await sendMail(conf.mail, '[dwatcher] Connection closed', `
|
await sendMail(conf.mail, `[dwatcher] [${os.hostname}] Connection closed`, `
|
||||||
<p>
|
<p>
|
||||||
Connection to ${target} was lost on ${moment().format('dd-MM-YYYY HH:mm:ss')}.
|
Connection to ${target} was lost on ${moment().format('dd-MM-YYYY HH:mm:ss')}.
|
||||||
</p>
|
</p>
|
||||||
@@ -59,7 +60,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')
|
||||||
await sendMail(conf.mail, '[dwatcher] Connection recovered', `
|
await sendMail(conf.mail, `[dwatcher] [${os.hostname}] Connection recovered`, `
|
||||||
<p>
|
<p>
|
||||||
Connection to ${target} was recovered on ${moment().format('dd-MM-YYYY HH:mm:ss')}.
|
Connection to ${target} was recovered on ${moment().format('dd-MM-YYYY HH:mm:ss')}.
|
||||||
</p>
|
</p>
|
||||||
@@ -70,7 +71,7 @@ export const mail = {
|
|||||||
onError: (conf: Conf, target: string) => {
|
onError: (conf: Conf, target: string) => {
|
||||||
return async (e: Error) => {
|
return async (e: Error) => {
|
||||||
console.error(e.message || e)
|
console.error(e.message || e)
|
||||||
// await sendMail(conf.mail, '[dwatcher] Connection error', `
|
// await sendMail(conf.mail, `[dwatcher] Connection error`, `
|
||||||
// <p>
|
// <p>
|
||||||
// Connection error with ${target} on ${moment().format('dd-MM-YYYY HH:mm:ss')}:
|
// Connection error with ${target} on ${moment().format('dd-MM-YYYY HH:mm:ss')}:
|
||||||
// </p>
|
// </p>
|
||||||
|
|||||||
Reference in New Issue
Block a user