-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexample.js
More file actions
28 lines (24 loc) · 812 Bytes
/
example.js
File metadata and controls
28 lines (24 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* Module dependencies.
*/
var http = require('http')
, cluster = require('cluster')
, mail = require('./');
var server = http.createServer(function(req, res){
// uncaught exceptions are automatically reported, however
// for exceptions that we have caught, typically within
// an error handler, we may report them with cluster.reportException()
try {
if (Math.random() > 0.9) throw new Error('fail!');
res.end('Hello World');
} catch (err) {
// we can also optionally send an arbitrary json object
// for use within our template
var data = { method: req.method, url: req.url, headers: req.headers };
cluster.mailException(err, data);
console.log('sent %s', err.message);
}
});
cluster = cluster(server)
.use(mail('tjholowayhuk@gmail.com'))
.listen(3000);