Skip to content

Commit 5c2440b

Browse files
committed
🎨 Removed tabs
1 parent acc971f commit 5c2440b

30 files changed

+9162
-9147
lines changed

.eslintrc.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
module.exports = {
2-
env: {
3-
node: true,
4-
commonjs: true,
5-
es2021: true,
6-
},
7-
extends: 'eslint:recommended',
8-
parserOptions: {
9-
ecmaVersion: 12,
10-
},
11-
rules: {
12-
indent: ['error', 'tab'],
13-
'linebreak-style': ['error', 'unix'],
14-
quotes: ['error', 'single'],
15-
semi: ['error', 'always'],
16-
},
2+
env: {
3+
node: true,
4+
commonjs: true,
5+
es2021: true,
6+
},
7+
extends: 'eslint:recommended',
8+
parserOptions: {
9+
ecmaVersion: 12,
10+
},
11+
rules: {
12+
indent: ['error', 2],
13+
'linebreak-style': ['error', 'unix'],
14+
quotes: ['error', 'single'],
15+
semi: ['error', 'always'],
16+
},
1717
};

.prettierrc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"singleQuote": true,
3-
"tabWidth": 2,
4-
"endOfLine": "lf",
5-
"semi": true,
6-
"trailingComma": "es5",
7-
"useTabs": true
2+
"singleQuote": true,
3+
"tabWidth": 2,
4+
"endOfLine": "lf",
5+
"semi": true,
6+
"trailingComma": "es5",
7+
"useTabs": false
88
}

.rotate.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module.exports = {
2-
filter(data) {
3-
return data.req;
4-
},
5-
output: {
6-
path: './proxy.log',
7-
options: {
8-
path: './logs',
9-
interval: '1d',
10-
},
11-
},
2+
filter(data) {
3+
return data.req;
4+
},
5+
output: {
6+
path: './proxy.log',
7+
options: {
8+
path: './logs',
9+
interval: '1d',
10+
},
11+
},
1212
};

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ Read more about [📝 design](docs/design.md)
1010
- [Development Internals](#development-internals)
1111

1212
### ✨ How to contribute
13+
1314
We are very happy to receive and merge your contributions into this repository!
1415

1516
To contribute via pull request, follow these steps:
1617

1718
1. Create an issue describing the feature you want to work on (or
1819
have a look at the [issues](https://github.com/browserstack/ws-reconnect-proxy/issues))
19-
2. Write your code, tests and format them with ``npm run format``
20+
2. Write your code, tests and format them with `npm run format`
2021
3. Create a pull request describing your changes
2122

22-
2323
Your pull request will be reviewed by a maintainer, who will get
2424
back to you about any necessary changes or questions.
2525

@@ -51,7 +51,8 @@ npm run format
5151

5252
### 🚀 Run proxy
5353

54-
🔧 Before, executing proxy create the `config.json` by running the following command:
54+
🔧 Before, executing proxy create the `config.json` by running the following command:
55+
5556
```bash
5657
cp lib/config/config.json.sample lib/config/config.json
5758
```
@@ -64,7 +65,8 @@ Then execute proxy by running the following command:
6465
npm run start
6566
```
6667

67-
*NOTE: By default it runs in `dev` environment you can configure your env by the following command:*
68+
_NOTE: By default it runs in `dev` environment you can configure your env by the following command:_
69+
6870
```bash
6971
NODE_ENV=<env> node cluster.js
70-
```
72+
```

cluster.js

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,58 +11,58 @@ const WORKER_CNT = config.workerVal;
1111
const activeWorkers = [];
1212

1313
const forceKill = (worker) => {
14-
if (!worker.isDead()) {
15-
logger.info(`Worker ${worker.process.pid} is ${worker.state}, Killing it`);
16-
worker.kill('SIGUSR2');
17-
}
14+
if (!worker.isDead()) {
15+
logger.info(`Worker ${worker.process.pid} is ${worker.state}, Killing it`);
16+
worker.kill('SIGUSR2');
17+
}
1818
};
1919

2020
const disconnectOldWorkers = () => {
21-
const len = activeWorkers.length;
22-
for (let i = 0; i < len; i++) {
23-
const oldWorker = activeWorkers.shift();
24-
oldWorker.disconnect();
25-
setTimeout(() => forceKill(oldWorker), config.workerKillTimer);
26-
}
21+
const len = activeWorkers.length;
22+
for (let i = 0; i < len; i++) {
23+
const oldWorker = activeWorkers.shift();
24+
oldWorker.disconnect();
25+
setTimeout(() => forceKill(oldWorker), config.workerKillTimer);
26+
}
2727
};
2828

2929
const spawnNewWorkers = () => {
30-
if (cluster.isMaster) {
31-
for (let i = 0; i < WORKER_CNT; ++i) {
32-
const worker = cluster.fork();
33-
worker.on('error', (err) => {
34-
logger.error(`Received error event on ${worker.id} : ${err}`);
35-
});
36-
logger.info(`Created worker with id ${worker.id}`);
37-
activeWorkers.push(worker);
38-
}
39-
}
30+
if (cluster.isMaster) {
31+
for (let i = 0; i < WORKER_CNT; ++i) {
32+
const worker = cluster.fork();
33+
worker.on('error', (err) => {
34+
logger.error(`Received error event on ${worker.id} : ${err}`);
35+
});
36+
logger.info(`Created worker with id ${worker.id}`);
37+
activeWorkers.push(worker);
38+
}
39+
}
4040
};
4141

4242
if (cluster.isMaster) {
43-
cluster.on('online', function (worker) {
44-
logger.info(`Worker ${worker.process.pid} is online`);
45-
});
43+
cluster.on('online', function (worker) {
44+
logger.info(`Worker ${worker.process.pid} is online`);
45+
});
4646

47-
cluster.on('exit', (worker, code, signal) => {
48-
logger.info(
49-
`worker ${worker.process.pid} died with signal ${signal} code ${code}`
50-
);
51-
if (activeWorkers.length == 0) spawnNewWorkers();
52-
});
47+
cluster.on('exit', (worker, code, signal) => {
48+
logger.info(
49+
`worker ${worker.process.pid} died with signal ${signal} code ${code}`
50+
);
51+
if (activeWorkers.length == 0) spawnNewWorkers();
52+
});
5353

54-
spawnNewWorkers();
54+
spawnNewWorkers();
5555

56-
let currTime = Date.now();
57-
watch('tmp/restart.txt', () => {
58-
if (Date.now() > currTime) {
59-
currTime = Date.now();
60-
disconnectOldWorkers();
61-
spawnNewWorkers();
62-
}
63-
});
56+
let currTime = Date.now();
57+
watch('tmp/restart.txt', () => {
58+
if (Date.now() > currTime) {
59+
currTime = Date.now();
60+
disconnectOldWorkers();
61+
spawnNewWorkers();
62+
}
63+
});
6464
} else {
65-
new Proxy();
65+
new Proxy();
6666
}
6767

6868
process.on('uncaughtException', new ProcessHandler().onError);

0 commit comments

Comments
 (0)