This commit is contained in:
AJ ONeal 2016-08-10 13:39:58 -04:00
parent af07bc735b
commit 5a710a729f
1 changed files with 30 additions and 7 deletions

View File

@ -1,12 +1,11 @@
'use strict'; 'use strict';
var cluster = require('cluster'); var cluster = require('cluster');
var master;
function runMaster() {
var numCores = 2; // // Math.max(2, require('os').cpus().length) var numCores = 2; // // Math.max(2, require('os').cpus().length)
var i; var i;
var master = require('./master').create({
if (cluster.isMaster) {
master = require('./master').create({
debug: true debug: true
@ -32,8 +31,9 @@ if (cluster.isMaster) {
master.addWorker(cluster.fork()); master.addWorker(cluster.fork());
} }
} }
else {
require('./worker').create({ function runWorker() {
var worker = require('./worker').create({
debug: true debug: true
// We want both to renew well before the expiration date // We want both to renew well before the expiration date
@ -42,6 +42,13 @@ else {
, notBefore: 15 * 24 * 60 * 60 * 1000 , notBefore: 15 * 24 * 60 * 60 * 1000
, notAfter: 10 * 24 * 60 * 60 * 1000 // optional , notAfter: 10 * 24 * 60 * 60 * 1000 // optional
/*
, getChallenge: function (domain, token, cb) {
// the default behavior is to pass a message to master,
// but if needed for performance, that can be overwritten here
cb(null, );
}
*/
, approveDomains: function (opts, certs, cb) { , approveDomains: function (opts, certs, cb) {
// opts = { domains, email, agreeTos, tosUrl } // opts = { domains, email, agreeTos, tosUrl }
// certs = { subject, altnames, expiresAt, issuedAt } // certs = { subject, altnames, expiresAt, issuedAt }
@ -68,4 +75,20 @@ else {
cb(null, { options: opts }); cb(null, { options: opts });
} }
}); });
function app(req, res) {
res.end("Hello, World!");
}
var plainServer = require('http').createServer(worker.handleAcmeAndRedirectToHttps);
var server = require('https').createServer(worker.httpsOptions, worker.handleAcmeAndUse(app));
plainServer.listen(80);
server.listen(443);
}
if (cluster.isMaster) {
runMaster();
}
else {
runWorker();
} }