Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
/chat_servicePublic archive

Commitd5cc248

Browse files
committed
__INITIAL__ initial commit
0 parents  commitd5cc248

File tree

55 files changed

+14714
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+14714
-0
lines changed

‎.eslintrc.json‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"env": {
3+
"es6":true,
4+
"node":true
5+
},
6+
"extends": ["eslint:recommended"],
7+
"parserOptions": {
8+
"ecmaVersion":8,
9+
"sourceType":"module"
10+
},
11+
"rules": {
12+
"no-multiple-empty-lines": [
13+
"warn"
14+
],
15+
"indent": [
16+
"warn",
17+
"tab"
18+
],
19+
"linebreak-style": [
20+
"error",
21+
"unix"
22+
],
23+
"quotes": [
24+
"error",
25+
"single"
26+
],
27+
"semi": [
28+
"warn",
29+
"always"
30+
],
31+
"no-var": [
32+
"warn"
33+
],
34+
"prefer-const": [
35+
"warn"
36+
],
37+
"no-unreachable": [
38+
"error"
39+
]
40+
}
41+
42+
}
43+

‎.gitignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dist
2+
package-lock.json
3+
.babelrc
4+
.env
5+
.eslintignore
6+
node_modules

‎.vscode/launch.json‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version":"0.2.0",
6+
"configurations": [
7+
{
8+
"type":"node",
9+
"request":"attach",
10+
"name":"Attach by Process ID",
11+
"processId":"${command:PickProcess}"
12+
},
13+
{
14+
"type":"node",
15+
"request":"launch",
16+
"name":"Launch Program",
17+
"program":"${workspaceFolder}/chat_service.js"
18+
}
19+
]
20+
}

‎.vscode/sftp.json‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"protocol":"sftp",
3+
"host":"46.105.163.140",
4+
"port":3031,
5+
"username":"goftare_test",
6+
"remotePath":"./www/chat_service",
7+
"password":"goftare_test_v2_sonofaq_11142_ovh",
8+
"name":"goftare_test",
9+
"ignore": [
10+
".eslintignore",
11+
".vscode",
12+
".git",
13+
".DS_Store",
14+
"dist",
15+
"node_modules",
16+
"package-lock.json",
17+
"coverage",
18+
"out"
19+
]
20+
}

‎bin/www.js‎

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
7+
varapp=require('../chat_service');
8+
vardebug=require('debug')('goftare:server');
9+
varhttp=require('http');
10+
constpid=process.pid;
11+
constcluster=require('cluster');
12+
constnumCPUs=require('os').cpus().length;
13+
constdotenv=require('dotenv').config();
14+
conststart_dao=require('../lib/dao/start_dao');
15+
16+
17+
/**
18+
* Get port from environment and store in Express.
19+
*/
20+
21+
22+
if(cluster.isMaster){
23+
console.log(`Master${process.pid} is running`);
24+
25+
// Fork workers.
26+
for(leti=0;i<numCPUs;i++){
27+
cluster.fork();
28+
}
29+
30+
cluster.on('exit',(worker,code,signal)=>{
31+
console.log(`worker${worker.process.pid} died`);
32+
});
33+
}else{
34+
// Workers can share any TCP connection
35+
36+
37+
varport=normalizePort(process.env.PORT||'3000');
38+
app.set('port',port);
39+
40+
/**
41+
* Create HTTP server.
42+
*/
43+
44+
varserver=http.createServer(app);
45+
exports.io=require('socket.io')(server,{
46+
pingTimeout:15000,
47+
pingInterval:3000,
48+
transports:['websocket'],
49+
cookie:false
50+
})
51+
52+
/**
53+
* Listen on provided port, on all network interfaces.
54+
*/
55+
56+
server.listen(port,()=>{
57+
constflushed=start_dao.flushDB();
58+
if(flushed){
59+
console.log(`Started process${pid}`);
60+
}
61+
});
62+
server.on('error',onError);
63+
server.on('listening',onListening);
64+
console.log(`server is running on port${process.env.PORT}`);
65+
66+
/**
67+
* Normalize a port into a number, string, or false.
68+
*/
69+
70+
functionnormalizePort(val){
71+
varport=parseInt(val,10);
72+
73+
if(isNaN(port)){
74+
// named pipe
75+
returnval;
76+
}
77+
78+
if(port>=0){
79+
// port number
80+
returnport;
81+
}
82+
83+
returnfalse;
84+
}
85+
86+
/**
87+
* Event listener for HTTP server "error" event.
88+
*/
89+
90+
functiononError(error){
91+
if(error.syscall!=='listen'){
92+
throwerror;
93+
}
94+
95+
varbind=typeofport==='string'
96+
?'Pipe '+port
97+
:'Port '+port;
98+
99+
// handle specific listen errors with friendly messages
100+
switch(error.code){
101+
case'EACCES':
102+
console.error(bind+' requires elevated privileges');
103+
process.exit(1);
104+
break;
105+
case'EADDRINUSE':
106+
console.error(bind+' is already in use');
107+
process.exit(1);
108+
break;
109+
default:
110+
throwerror;
111+
}
112+
}
113+
114+
/**
115+
* Event listener for HTTP server "listening" event.
116+
*/
117+
118+
functiononListening(){
119+
varaddr=server.address();
120+
varbind=typeofaddr==='string'
121+
?'pipe '+addr
122+
:'port '+addr.port;
123+
debug('Listening on '+bind);
124+
}
125+
126+
127+
console.log(`Worker${process.pid} started`);
128+
exports.shit="shit"
129+
}
130+
131+

‎chat_service.js‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
constapp=require('express')();
2+
constwinston=require('./lib/utils/logger');
3+
constserver=require('http').createServer(app);
4+
constexpress=require('express');
5+
constconfig=require('./lib/config/config');
6+
constdebug=require('debug')('goftare:http');
7+
constmorgan=require('morgan');
8+
constpath=require('path');
9+
constcookieParser=require('cookie-parser');
10+
constInit=require('./lib/utils/Init');
11+
constRoutes=require('./routes/index');
12+
constsocketHandler=require('./lib/handlers/socket_handler');
13+
conststart_dao=require('./lib/dao/start_dao');
14+
constio=require('socket.io')(server,{
15+
transports:['websocket'],
16+
});
17+
//const errorHandler = require('./lib/handlers/errorHandler')
18+
//View engine setup
19+
//const app.set('views', path.join(__dirname, 'views'))
20+
//const app.set('view engine', 'jade')
21+
// MiddleWares
22+
app.use(morgan('combined',{stream:winston.stream}));
23+
app.use(express.json());
24+
app.use(express.urlencoded({extended:false}));
25+
app.use(cookieParser());
26+
app.use(express.static(path.join(__dirname,'public')));
27+
app.use(express.static(path.join(__dirname,'../landing')));
28+
29+
//initializing
30+
Init(app);
31+
socketHandler(io);
32+
Routes(app);
33+
//errorHandler(app)
34+
35+
36+
server.listen(config.PORT,()=>{
37+
constflushed=start_dao.flushDB();
38+
if(flushed){
39+
debug(`server is running on${config.PORT}`);
40+
}
41+
});
42+
43+
module.exports=app;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp