Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit cfe0beb

Browse files
committed
新增 首次提交
1 parent 23901f7 commit cfe0beb

21 files changed

Lines changed: 2461 additions & 0 deletions

.eslintrc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
env: {
3+
commonjs: true,
4+
es6: true,
5+
node: true
6+
},
7+
extends: "eslint:recommended",
8+
globals: {
9+
Atomics: "readonly",
10+
SharedArrayBuffer: "readonly"
11+
},
12+
parserOptions: {
13+
ecmaVersion: 2018
14+
},
15+
rules: {}
16+
};

.gitignore

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# myself files
2+
server/
3+
users/
4+
.vscode/
5+
testServer/
6+
*.exe
7+
*.zip
8+
docker_temp/
9+
toprettier.bat
10+
11+
# config files
12+
users/*.json
13+
server/*.json
14+
public/*.json
15+
McserverConfig.json
16+
core/*.json
17+
public/common/URL.js
18+
property.js
19+
20+
#vscode
21+
*.code-workspace
22+
23+
# node
24+
node_modules/
25+
26+
# tmp
27+
tmp_files/
28+
29+
# Logs
30+
logs
31+
*.log
32+
npm-debug.log*
33+
yarn-debug.log*
34+
yarn-error.log*
35+
36+
# Runtime data
37+
pids
38+
*.pid
39+
*.seed
40+
*.pid.lock
41+
42+
# Directory for instrumented libs generated by jscoverage/JSCover
43+
lib-cov
44+
45+
# Coverage directory used by tools like istanbul
46+
coverage
47+
48+
# nyc test coverage
49+
.nyc_output
50+
51+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
52+
.grunt
53+
54+
# Bower dependency directory (https://bower.io/)
55+
bower_components
56+
57+
# node-waf configuration
58+
.lock-wscript
59+
60+
# Compiled binary addons (http://nodejs.org/api/addons.html)
61+
build/Release
62+
63+
# Dependency directories
64+
node_modules/
65+
jspm_packages/
66+
67+
# Typescript v1 declaration files
68+
typings/
69+
70+
# Optional npm cache directory
71+
.npm
72+
73+
# Optional eslint cache
74+
.eslintcache
75+
76+
# Optional REPL history
77+
.node_repl_history
78+
79+
# Output of 'npm pack'
80+
*.tgz
81+
82+
# Yarn Integrity file
83+
.yarn-integrity
84+
85+
# dotenv environment variables file
86+
.env
87+

.prettierignore

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
public/common/bootstrap/
2+
public/common/echarts-dist/
3+
public/common/vue/
4+
public/common/jquery-3.2.1.min.js
5+
public/common/xterm.css
6+
public/common/xterm.js
7+
public/common/xterm.js.map
8+
public/common/echarts.js
9+
public/onlinefs_public/
10+
public/login/static/
11+
public/login2/static/
12+
public/login3/static/
13+
README.md
14+
README-traditional.md
15+
16+
# self files
17+
server/
18+
users/
19+
.vscode/
20+
testServer/
21+
*.exe
22+
*.zip
23+
docker_temp/
24+
25+
26+
# config files
27+
users/*.json
28+
server/*.json
29+
public/*.json
30+
McserverConfig.json
31+
core/*.json
32+
public/common/URL.js
33+
property.js
34+
35+
#vscode
36+
*.code-workspace
37+
38+
# node
39+
node_modules/
40+
41+
# tmp
42+
tmp_files/
43+
44+
# Logs
45+
logs
46+
*.log
47+
npm-debug.log*
48+
yarn-debug.log*
49+
yarn-error.log*
50+
51+
# Runtime data
52+
pids
53+
*.pid
54+
*.seed
55+
*.pid.lock
56+
57+
# Directory for instrumented libs generated by jscoverage/JSCover
58+
lib-cov
59+
60+
# Coverage directory used by tools like istanbul
61+
coverage
62+
63+
# nyc test coverage
64+
.nyc_output
65+
66+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
67+
.grunt
68+
69+
# Bower dependency directory (https://bower.io/)
70+
bower_components
71+
72+
# node-waf configuration
73+
.lock-wscript
74+
75+
# Compiled binary addons (http://nodejs.org/api/addons.html)
76+
build/Release
77+
78+
# Dependency directories
79+
node_modules/
80+
jspm_packages/
81+
82+
# Typescript v1 declaration files
83+
typings/
84+
85+
# Optional npm cache directory
86+
.npm
87+
88+
# Optional eslint cache
89+
.eslintcache
90+
91+
# Optional REPL history
92+
.node_repl_history
93+
94+
# Output of 'npm pack'
95+
*.tgz
96+
97+
# Yarn Integrity file
98+
.yarn-integrity
99+
100+
# dotenv environment variables file
101+
.env
102+

.prettierrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"printWidth": 200,
3+
"trailingComma": "none"
4+
}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
MCSManager 守护进程程序
2+
------
3+
4+
适用于 MCSManager 项目的守护进程,正在开发中...

app.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* @Author: Copyright(c) 2020 Suwings
3+
* @Date: 2020-11-23 17:45:02
4+
* @LastEditTime: 2020-11-23 17:51:11
5+
* @Description: 守护进程启动文件
6+
*/
7+
8+
const { config } = require("./service/config");
9+
const { logger } = require("./service/log");
10+
11+
logger.info(`欢迎使用 Daemon 程序.`);
12+
13+
const io = require("socket.io")(config.port, {
14+
serveClient: false,
15+
pingInterval: 10000,
16+
pingTimeout: 10000,
17+
cookie: false
18+
});
19+
20+
const router = require("./service/router");
21+
const protocol = require("./service/protocol");
22+
23+
io.on("connection", (socket) => {
24+
logger.info(`会话 ${socket.id} 已链接`);
25+
26+
// 加入到全局Socket对象
27+
protocol.addGlobalSocket(socket);
28+
29+
// Socket.io 请求转发到自定义路由控制器
30+
router.navigation(socket);
31+
32+
// 断开事件
33+
socket.on("disconnect", () => {
34+
// 从全局Socket对象移除
35+
protocol.delGlobalSocket(socket);
36+
socket.removeAllListeners(socket.eventNames());
37+
logger.info(`会话 ${socket.id} 已断开`);
38+
});
39+
});
40+
41+
// 错误报告监听
42+
process.on("uncaughtException", function (err) {
43+
logger.error(`错误报告(uncaughtException): ${err}`);
44+
});
45+
46+
// 错误报告监听
47+
process.on("unhandledRejection", (reason, p) => {
48+
logger.error(`错误报告(unhandledRejection): ${reason}\n${p}`);
49+
});
50+
51+
// 启动完毕
52+
logger.info(`守护进程已成功启动.`);
53+
logger.info(`正在监听 ${config.port} 端口,等待数据...`);

0 commit comments

Comments
 (0)