diff options
author | Girish Ramakrishnan <girish@cloudron.io> | 2020-12-11 12:02:32 -0800 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-12-12 08:50:59 +0100 |
commit | 75594f474a3e04086b37a014d23e89780ca67458 (patch) | |
tree | d09e3f850fbc5b95462070412f4fb120e524302e | |
parent | fffc7c08649ead08007f9cf6d80d87a14ae05703 (diff) | |
download | PeerTube-75594f474a3e04086b37a014d23e89780ca67458.tar.gz PeerTube-75594f474a3e04086b37a014d23e89780ca67458.tar.zst PeerTube-75594f474a3e04086b37a014d23e89780ca67458.zip |
do not crash if SMTP server is down
just log a warning if the SMTP server is down on startup time
fixes #3457
-rw-r--r-- | server.ts | 2 | ||||
-rw-r--r-- | server/lib/emailer.ts | 9 |
2 files changed, 5 insertions, 6 deletions
@@ -249,7 +249,7 @@ async function startApplication () { | |||
249 | Emailer.Instance.init() | 249 | Emailer.Instance.init() |
250 | 250 | ||
251 | await Promise.all([ | 251 | await Promise.all([ |
252 | Emailer.Instance.checkConnectionOrDie(), | 252 | Emailer.Instance.checkConnection(), |
253 | JobQueue.Instance.init() | 253 | JobQueue.Instance.init() |
254 | ]) | 254 | ]) |
255 | 255 | ||
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts index 650a3c090..e4e093fbc 100644 --- a/server/lib/emailer.ts +++ b/server/lib/emailer.ts | |||
@@ -107,18 +107,18 @@ class Emailer { | |||
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | async checkConnectionOrDie () { | 110 | async checkConnection () { |
111 | if (!this.transporter || CONFIG.SMTP.TRANSPORT !== 'smtp') return | 111 | if (!this.transporter || CONFIG.SMTP.TRANSPORT !== 'smtp') return |
112 | 112 | ||
113 | logger.info('Testing SMTP server...') | 113 | logger.info('Testing SMTP server...') |
114 | 114 | ||
115 | try { | 115 | try { |
116 | const success = await this.transporter.verify() | 116 | const success = await this.transporter.verify() |
117 | if (success !== true) this.dieOnConnectionFailure() | 117 | if (success !== true) this.warnOnConnectionFailure() |
118 | 118 | ||
119 | logger.info('Successfully connected to SMTP server.') | 119 | logger.info('Successfully connected to SMTP server.') |
120 | } catch (err) { | 120 | } catch (err) { |
121 | this.dieOnConnectionFailure(err) | 121 | this.warnOnConnectionFailure(err) |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
@@ -636,9 +636,8 @@ class Emailer { | |||
636 | } | 636 | } |
637 | } | 637 | } |
638 | 638 | ||
639 | private dieOnConnectionFailure (err?: Error) { | 639 | private warnOnConnectionFailure (err?: Error) { |
640 | logger.error('Failed to connect to SMTP %s:%d.', CONFIG.SMTP.HOSTNAME, CONFIG.SMTP.PORT, { err }) | 640 | logger.error('Failed to connect to SMTP %s:%d.', CONFIG.SMTP.HOSTNAME, CONFIG.SMTP.PORT, { err }) |
641 | process.exit(-1) | ||
642 | } | 641 | } |
643 | 642 | ||
644 | static get Instance () { | 643 | static get Instance () { |