fix: better debugging experience with cluster (#2447)
This commit is contained in:
parent
2f1aeb4d84
commit
f73690682e
|
|
@ -474,3 +474,46 @@ Add the script into [/lib/router.js](https://github.com/DIYgod/RSSHub/blob/maste
|
|||
|
||||
1. [Telegram Group](https://t.me/rsshub)
|
||||
2. [GitHub Issues](https://github.com/DIYgod/RSSHub/issues)
|
||||
|
||||
## Some Tips for Development
|
||||
|
||||
### VS Code debug configuration
|
||||
|
||||
`.vscode/launch.js`
|
||||
|
||||
#### Debugging with nodemon
|
||||
|
||||
In terminal, run `npm run dev` or `yarn dev` to start debugging.
|
||||
|
||||
```json
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"name": "Node: Nodemon",
|
||||
"processId": "${command:PickProcess}",
|
||||
"restart": true,
|
||||
"protocol": "inspector"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Debugging without nodemon
|
||||
|
||||
```json
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"program": "${workspaceFolder}/lib/index.js",
|
||||
"env": { "NODE_ENV": "dev" }
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -488,3 +488,46 @@ ctx.state.data = {
|
|||
1. 请一定要注意把`<Route>`的标签关闭!
|
||||
|
||||
1. 执行 `npm run format` 自动标准化代码格式,提交代码, 然后提交 pull request
|
||||
|
||||
## 一些开发 tips
|
||||
|
||||
### VS Code 调试配置
|
||||
|
||||
`.vscode/launch.js`
|
||||
|
||||
#### 使用 nodemon 调试
|
||||
|
||||
在终端使用 `npm run dev` 或 `yarn dev` 开始调试。
|
||||
|
||||
```json
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"name": "Node: Nodemon",
|
||||
"processId": "${command:PickProcess}",
|
||||
"restart": true,
|
||||
"protocol": "inspector"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### 不使用 nodemon 调试
|
||||
|
||||
```json
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"program": "${workspaceFolder}/lib/index.js",
|
||||
"env": { "NODE_ENV": "dev" }
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ const apiResponseHandler = require('./middleware/api-response-handler');
|
|||
const cluster = require('cluster');
|
||||
const numCPUs = require('os').cpus().length;
|
||||
|
||||
if (cluster.isMaster && !config.disableCluster && process.env.NODE_ENV !== 'test') {
|
||||
if (cluster.isMaster && !config.disableCluster && process.env.NODE_ENV !== 'test' && process.env.NODE_ENV !== 'dev') {
|
||||
for (let i = 0; i < numCPUs; i++) {
|
||||
cluster.fork();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"start": "node lib/index.js",
|
||||
"dev": "nodemon $NODE_DEBUG_OPTION lib/index.js",
|
||||
"dev": "NODE_ENV=dev nodemon --inspect lib/index.js",
|
||||
"docs:dev": "vuepress dev docs",
|
||||
"docs:build": "vuepress build docs",
|
||||
"format": "eslint \"**/*.js\" --fix && node docs/format.js && prettier \"**/*.{js,json,md}\" --write",
|
||||
|
|
@ -118,4 +118,4 @@
|
|||
"_moduleAliases": {
|
||||
"@": "./lib"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue