core: disable cluster mode by default
This commit is contained in:
parent
e8ccc63d39
commit
66aef07e9c
@ -30,7 +30,6 @@ module.exports = function init() {
|
||||
const key = random('abcdefghjkmnpqrstuvwxyz23456789!@#$%^&*()_+<>?:|{}-=[];,./ABCDEFGHJKLMNPQRSTUVWXYZ', 16);
|
||||
const port = getRandomInt(1024, 65535);
|
||||
const timeout = getRandomInt(200, 1000);
|
||||
const workers = os.cpus().length;
|
||||
|
||||
const clientJson = {
|
||||
'host': '127.0.0.1',
|
||||
@ -59,7 +58,7 @@ module.exports = function init() {
|
||||
'dns': [],
|
||||
'dns_expire': 3600,
|
||||
'timeout': timeout,
|
||||
'workers': workers,
|
||||
'workers': 0,
|
||||
'log_level': 'info'
|
||||
};
|
||||
|
||||
@ -84,7 +83,7 @@ module.exports = function init() {
|
||||
'dns_expire': 3600,
|
||||
'redirect': '',
|
||||
'timeout': timeout,
|
||||
'workers': workers,
|
||||
'workers': 0,
|
||||
'log_level': 'info'
|
||||
};
|
||||
|
||||
|
@ -57,8 +57,8 @@ $ blinksocks init
|
||||
"dns_expire": 3600,
|
||||
// close inactive connection after timeout seconds
|
||||
"timeout": 600,
|
||||
// how many sub processes to create, default is the number of CPU cores, 0 to disable cluster mode
|
||||
"workers": 2,
|
||||
// how many sub processes to create, default is 0(disable cluster mode)
|
||||
"workers": 0,
|
||||
// log at the level, "error", "warn", "info", "verbose", "debug" or "silly"
|
||||
"log_level": "info"
|
||||
}
|
||||
@ -105,8 +105,8 @@ $ blinksocks init
|
||||
"redirect": "",
|
||||
// close inactive connection after timeout seconds
|
||||
"timeout": 600,
|
||||
// how many sub processes to create, default is the number of CPU cores, 0 to disable cluster mode
|
||||
"workers": 2,
|
||||
// how many sub processes to create, default is 0(disable cluster mode)
|
||||
"workers": 0,
|
||||
// log at the level, "error", "warn", "info", "verbose", "debug" or "silly"
|
||||
"log_level": "info"
|
||||
}
|
||||
@ -186,3 +186,17 @@ If you encounter **ENOTFOUND** every now and then, you would better custom dns s
|
||||
If no `dns` option or no ip provided in `dns`, blinksocks use system dns settings as usual.
|
||||
|
||||
See: https://github.com/blinksocks/blinksocks/issues/66
|
||||
|
||||
## Cluster Mode
|
||||
|
||||
You can enable cluster mode by setting `workers` greater than zero, cluster mode can take advantage of multi-core systems to handle the load.
|
||||
|
||||
`workers` is usually set to the number of cpu cores:
|
||||
|
||||
```
|
||||
{
|
||||
...
|
||||
"workers": 2
|
||||
...
|
||||
}
|
||||
```
|
||||
|
@ -3,7 +3,7 @@ import fs from 'fs';
|
||||
import os from 'os';
|
||||
import net from 'net';
|
||||
import {isValidPort} from '../utils';
|
||||
import {BLINKSOCKS_DIR, LOG_DIR, DEFAULT_LOG_LEVEL, DEFAULT_WORKERS} from './constants';
|
||||
import {BLINKSOCKS_DIR, LOG_DIR, DEFAULT_LOG_LEVEL} from './constants';
|
||||
import {DNS_DEFAULT_EXPIRE} from './dns-cache';
|
||||
|
||||
/**
|
||||
@ -202,7 +202,7 @@ export class Config {
|
||||
global.__IS_SERVER__ = !global.__IS_CLIENT__;
|
||||
global.__REDIRECT__ = json.redirect;
|
||||
global.__TIMEOUT__ = json.timeout * 1e3;
|
||||
global.__WORKERS__ = (json.workers !== undefined) ? json.workers : DEFAULT_WORKERS;
|
||||
global.__WORKERS__ = (json.workers !== undefined) ? json.workers : 0;
|
||||
global.__LOG_LEVEL__ = json.log_level || DEFAULT_LOG_LEVEL;
|
||||
global.__DNS_EXPIRE__ = (json.dns_expire !== undefined) ? json.dns_expire * 1e3 : DNS_DEFAULT_EXPIRE;
|
||||
global.__ALL_CONFIG__ = json;
|
||||
|
@ -15,7 +15,6 @@ const LOG_FILE_PATH = path.join(LOG_DIR,
|
||||
);
|
||||
const LOG_FILE_MAX_SIZE = 2 * 1024 * 1024; // 2MB
|
||||
const DEFAULT_LOG_LEVEL = 'info';
|
||||
const DEFAULT_WORKERS = os.cpus().length;
|
||||
|
||||
module.exports = {
|
||||
HOME_DIR,
|
||||
@ -23,6 +22,5 @@ module.exports = {
|
||||
LOG_DIR,
|
||||
LOG_FILE_PATH,
|
||||
LOG_FILE_MAX_SIZE,
|
||||
DEFAULT_LOG_LEVEL,
|
||||
DEFAULT_WORKERS
|
||||
DEFAULT_LOG_LEVEL
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user