clarify / normalize some options

This commit is contained in:
AJ ONeal 2016-08-12 03:48:21 -04:00
parent 6a7af7bdcb
commit d72c511449
2 changed files with 17 additions and 7 deletions

View File

@ -74,7 +74,7 @@ var cluster = require('cluster');
module.exports.init = function (sharedOpts) {
var cores = require('os').cpus();
var master = require('letsencrypt-cluster/master').create({
var leMaster = require('letsencrypt-cluster/master').create({
debug: sharedOpts.debug
, server: 'staging' // CHANGE TO PRODUCTION
@ -96,11 +96,21 @@ module.exports.init = function (sharedOpts) {
cores.forEach(function () {
var worker = cluster.fork();
master.addWorker(worker);
leMaster.addWorker(worker);
});
};
```
### API
All options are passed directly to `node-letsencrypt`
(in other works, `leMaster` is a `letsencrypt` instance),
but a few are only actually used by `letsencrypt-cluster`.
* `leMaster.approveDomains(options, certs, cb)` is special for `letsencrypt-cluster`, but will probably be included in `node-letsencrypt` in the future (no API change).
* `leMaster.addWorker(worker)` is added by `letsencrypt-cluster` and **must be called** for each new worker.
Worker
------
@ -115,7 +125,7 @@ If you want to a non-default `le.challenge`
'use strict';
module.exports.init = function (sharedOpts) {
var worker = require('../worker').create({
var leWorker = require('letsencrypt-cluster/worker').create({
debug: sharedOpts.debug
, renewWithin: sharedOpts.renewWithin
@ -161,10 +171,10 @@ module.exports.init = function (sharedOpts) {
}
var redirectHttps = require('redirect-https')();
var plainServer = require('http').createServer(worker.middleware(redirectHttps));
var plainServer = require('http').createServer(leWorker.middleware(redirectHttps));
plainServer.listen(80);
var server = require('https').createServer(worker.httpsOptions, worker.middleware(app));
var server = require('https').createServer(leWorker.httpsOptions, leWorker.middleware(app));
server.listen(443);
};
```

View File

@ -25,8 +25,8 @@ module.exports.create = function (opts) {
});
opts.sni = require('le-sni-auto').create({
notBefore: opts.notBefore || (10 * 24 * 60 * 60 * 1000)
, notAfter: opts.notAfter || (5 * 24 * 60 * 60 * 1000)
renewWithin: opts.renewWithin || (10 * 24 * 60 * 60 * 1000)
, renewBy: opts.renewBy || (5 * 24 * 60 * 60 * 1000)
, getCertificates: function (domain, certs, cb) {
var workerOptions = { domains: [ domain ] };
opts.approveDomains(workerOptions, certs, function (_err, results) {