aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-01-08 15:51:52 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-01-09 11:15:15 +0100
commit89ada4e26ca1df8ff0dd02acda1d1661f121a294 (patch)
treeb8c8d373d8140227c3b73bbf14d5e1b15d877ee2 /shared
parent43483d12963ed7a82adee2e35a7bcb7e55e54b3e (diff)
downloadPeerTube-89ada4e26ca1df8ff0dd02acda1d1661f121a294.tar.gz
PeerTube-89ada4e26ca1df8ff0dd02acda1d1661f121a294.tar.zst
PeerTube-89ada4e26ca1df8ff0dd02acda1d1661f121a294.zip
Fix socket.io websocket connection
Diffstat (limited to 'shared')
-rw-r--r--shared/utils/miscs/email.ts17
1 files changed, 11 insertions, 6 deletions
diff --git a/shared/utils/miscs/email.ts b/shared/utils/miscs/email.ts
index 108f7d3d9..6fac7621f 100644
--- a/shared/utils/miscs/email.ts
+++ b/shared/utils/miscs/email.ts
@@ -1,22 +1,20 @@
1import * as child from 'child_process' 1import { fork, ChildProcess } from 'child_process'
2 2
3class MockSmtpServer { 3class MockSmtpServer {
4 4
5 private static instance: MockSmtpServer 5 private static instance: MockSmtpServer
6 private started = false 6 private started = false
7 private emailChildProcess: child.ChildProcess 7 private emailChildProcess: ChildProcess
8 private emails: object[] 8 private emails: object[]
9 9
10 private constructor () { 10 private constructor () {
11 this.emailChildProcess = child.fork(`${__dirname}/email-child-process`, [], { silent: true }) 11 this.emailChildProcess = fork(`${__dirname}/email-child-process`, [])
12
12 this.emailChildProcess.on('message', (msg) => { 13 this.emailChildProcess.on('message', (msg) => {
13 if (msg.email) { 14 if (msg.email) {
14 return this.emails.push(msg.email) 15 return this.emails.push(msg.email)
15 } 16 }
16 }) 17 })
17 process.on('exit', () => {
18 this.emailChildProcess.kill()
19 })
20 } 18 }
21 19
22 collectEmails (emailsCollection: object[]) { 20 collectEmails (emailsCollection: object[]) {
@@ -43,6 +41,13 @@ class MockSmtpServer {
43 }) 41 })
44 } 42 }
45 43
44 kill () {
45 process.kill(this.emailChildProcess.pid)
46
47 this.emailChildProcess = null
48 MockSmtpServer.instance = null
49 }
50
46 static get Instance () { 51 static get Instance () {
47 return this.instance || (this.instance = new this()) 52 return this.instance || (this.instance = new this())
48 } 53 }