mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-09-11 07:34:48 +08:00
allow to use "cpus" as process count
This commit is contained in:
parent
be50d27467
commit
131757bd82
2 changed files with 20 additions and 15 deletions
|
@ -8,21 +8,10 @@
|
|||
ident="wildduck"
|
||||
|
||||
# how many processes to start
|
||||
# either a number for specific process count or "cpus" for machine thread count
|
||||
processes=1
|
||||
|
||||
# Default quota storage in MB (can be overriden per user)
|
||||
# Deprecated option. Use 'const:max:storage' setting instead
|
||||
#maxStorage=1024
|
||||
|
||||
# Default smtp recipients for 24h (can be overriden per user)
|
||||
# Deprecated option. Use 'const:max:recipients' setting instead
|
||||
#maxRecipients=2000
|
||||
|
||||
# default forwarded messages for 24h (can be overriden per user)
|
||||
# Deprecated option. Use 'const:max:forwards' setting instead
|
||||
#maxForwards=2000
|
||||
|
||||
# If usernames are not email addresses then use this domain as hostname part
|
||||
# If usernames are not email addresses then use this domain as default hostname part
|
||||
#emailDomain="mydomain.info"
|
||||
|
||||
[dbs]
|
||||
|
|
20
server.js
20
server.js
|
@ -13,6 +13,7 @@ if (process.env.NODE_CONFIG_ONLY === 'true') {
|
|||
|
||||
const errors = require('./lib/errors');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const log = require('npmlog');
|
||||
const packageData = require('./package.json');
|
||||
|
||||
|
@ -42,7 +43,22 @@ const printLogo = () => {
|
|||
log.info('App', '');
|
||||
};
|
||||
|
||||
if (!config.processes || config.processes <= 1) {
|
||||
let processCount = config.processes;
|
||||
if (processCount) {
|
||||
if (/^\s*cpus\s*$/i.test(processCount)) {
|
||||
processCount = os.cpus().length;
|
||||
}
|
||||
|
||||
if (typeof processCount !== 'number' && !isNaN(processCount)) {
|
||||
processCount = Number(processCount);
|
||||
}
|
||||
|
||||
if (isNaN(processCount)) {
|
||||
processCount = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!processCount || processCount <= 1) {
|
||||
printLogo();
|
||||
if (config.ident) {
|
||||
process.title = config.ident;
|
||||
|
@ -70,7 +86,7 @@ if (!config.processes || config.processes <= 1) {
|
|||
};
|
||||
|
||||
// Fork workers.
|
||||
for (let i = 0; i < config.processes; i++) {
|
||||
for (let i = 0; i < processCount; i++) {
|
||||
forkWorker();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue