Skip to content

Commit

Permalink
server with extremely simple features / publish web&game server&clien…
Browse files Browse the repository at this point in the history
…t code
  • Loading branch information
JJoriping committed Feb 14, 2017
1 parent b42bd44 commit 327e26e
Show file tree
Hide file tree
Showing 648 changed files with 609,813 additions and 26 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Client/node_modules
Server/node_modules
Server/run.bat
Server/node_modules
Server/lib/node_modules
2 changes: 1 addition & 1 deletion Client/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ html
head
title= locals.title
body
p Hello, World!
p KKuTu Client is under construction...
13 changes: 13 additions & 0 deletions KKUTU_ERROR.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This is an error log file of the game server.
You may use like `tail -f KKUTU_ERROR.log` to watch this.
:8496 [2017-02-14 18:45:19] ERROR: TypeError: Cannot read property 'getSurround' of undefined
TypeError: Cannot read property 'getSurround' of undefined
at D:\KKuTu\Server\lib\Game\kkutu.js:1197:22
at then (D:\KKuTu\Server\lib\sub\lizard.js:32:8)
at my.roundEnd (D:\KKuTu\Server\lib\Game\kkutu.js:1191:19)
at exports.roundReady (D:\KKuTu\Server\lib\Game\games\classic.js:129:6)
at my.route.my.routeSync (D:\KKuTu\Server\lib\Game\kkutu.js:1306:13)
at Timeout.my.roundReady (D:\KKuTu\Server\lib\Game\kkutu.js:1112:13)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
61 changes: 58 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# KKuTu
- [English](#english)
- [한국어](#한국어)

## English
> Rule the words! KKuTu Online
Expand All @@ -8,8 +11,33 @@ This repository provides you what you have to prepare to play **KKuTu**.

### KKuTu Client
- Under construction...
### KKuTu Server
- Under construction...

### KKuTu server
#### For Windows
1. Download or clone this repository to your machine.
1. Install [node.js](https://nodejs.org/en/) and npm(this will be installed automatically).
1. Install [PostgreSQL](https://www.postgresql.org/) database server and pgAdmin(this will be installed automatically).
1. Run pgAdmin and put the SQL file(`./db.sql`) into your database.
* For further details, visit [my blog][dev-blog].
1. Run the batch file(`./server-setup.bat`).
1. Run the batch file(`./Server/run.bat`).
* If you want to close the server, it is recommended that closing not the command prompt window, but the window generated by the command.

#### For Linux
1. Download or clone this repository to your machine.
1. Install *node.js* and *npm* via a package manager.
1. Install *PostgreSQL* database server via a package manager.
1. Put the SQL file(`./db.sql`) into your database.
1. Run a command like: `sudo su -u postgres psql --quiet main < ./db.sql`
1. Run the shell script file(`./server-setup.bat`). (It is a bat file for Windows but it will also work on Linux.)
1. Run these on working directory `./Server`:
1. (Web server) `node lib/Web/cluster.js 1`
1. (Game server) `node lib/Game/cluster.js 0 1`

#### Common
- You should edit the file(`./Server/lib/sub/global.json`) to connect to your PostgreSQL database server.
- The host `127.0.0.2` is reserved for connections between your web server and game server.
- Once the server is successfully installed, you can do just the last step of above-mentioned guideline whenever you want to run the server.

## 한국어
> 글자로 놀자! 끄투 온라인
Expand All @@ -20,5 +48,32 @@ This repository provides you what you have to prepare to play **KKuTu**.

### 끄투 클라이언트
- 공사 중...

### 끄투 서버
- 공사 중...
#### Windows 전용
1. 이 레포지토리를 내려받습니다.
1. [node.js](https://nodejs.org/ko/) 인스톨러를 내려받아 npm(자동으로 설치됨)과 함께 설치합니다.
1. [PostgreSQL](https://www.postgresql.org/) 인스톨러를 내려받아 pgAdmin(자동으로 설치됨)과 함께 설치합니다.
1. pgAdmin을 실행시키고 SQL 파일(`./db.sql`)을 데이터베이스에 입력시킵니다.
* 자세한 과정은 [개발자 블로그][dev-blog]를 참고하세요.
1. 배치 파일(`./server-setup.bat`)을 실행시킵니다.
1. 배치 파일(`./Server/run.bat`)을 실행시킵니다.
* 되도록 이 배치 파일을 직접 종료하지 말고 이를 실행시켜 나타나는 창을 종료하세요.

#### Linux 전용
1. 이 레포지토리를 내려받습니다.
1. 패키지 매니저를 이용하여 *node.js**npm*을 설치합니다.
1. 패키지 매니저를 이용하여 *PostgreSQL**psql*을 설치합니다.
1. SQL 파일(`./db.sql`)을 데이터베이스에 입력시킵니다.
1. 명령어를 다음 예와 같이 입력할 수 있습니다: `sudo su -u postgres psql --quite main < ./db.sql`
1. 섈 스크립트 파일(`./server-setup.bat`)을 실행시킵니다. (Windows 전용 파일이지만 Linux에서도 작동합니다.)
1. 경로 `./Server`에서 다음 명령어들을 실행합니다:
1. (웹 서버) `node lib/Web/cluster.js 1`
1. (게임 서버) `node lib/Game/cluster.js 0 1`

#### 공통
- PostgreSQL 데이터베이스 서버에 접속하기 위해서는 설정 파일(`./Server/lib/sub/global.json`)에서 `PG_PASS` 값을 수정해야 합니다.
- 호스트 `127.0.0.2`는 웹 서버와 게임 서버 사이의 연결을 위해 예약된 주소이므로 이 주소를 사용하지 말아야 합니다.
- 서버가 정상적으로 설치된 다음부터는 서버를 실행시키기 위해서 가장 마지막 단계만 수행하면 됩니다.

[dev-blog]: http://blog.jjo.kr/
6 changes: 0 additions & 6 deletions Server/index.pug

This file was deleted.

42 changes: 42 additions & 0 deletions Server/lib/Game/cluster.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
var Cluster = require("cluster");
var Const = require('../const');
var JLog = require('../sub/jjlog');
var SID = Number(process.argv[2]);
var CPU = Number(process.argv[3]); //require("os").cpus().length;

if(isNaN(SID)){
if(process.argv[2] == "test"){
global.test = true;
CPU = 1;
}else{
console.log(`Invalid Server ID ${process.argv[2]}`);
process.exit(1);
}
}
if(isNaN(CPU)){
console.log(`Invalid CPU Number ${process.argv[3]}`);
process.exit(1);
}
if(Cluster.isMaster){
var channels = {}, chan;
var i;

for(i=0; i<CPU; i++){
chan = i + 1;
channels[chan] = Cluster.fork({ SERVER_NO_FORK: true, KKUTU_PORT: Const.MAIN_PORTS[SID] + 416 + i, CHANNEL: chan });
}
Cluster.on('exit', function(w){
for(i in channels){
if(channels[i] == w){
chan = Number(i);
break;
}
}
JLog.error(`Worker @${chan} ${w.process.pid} died`);
channels[chan] = Cluster.fork({ SERVER_NO_FORK: true, KKUTU_PORT: Const.MAIN_PORTS[SID] + 416 + (chan - 1), CHANNEL: chan });
});
process.env['KKUTU_PORT'] = Const.MAIN_PORTS[SID];
require("./master.js").init(SID.toString(), channels);
}else{
require("./slave.js");
}
40 changes: 40 additions & 0 deletions Server/lib/Game/games/_form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var Const = require('../../const');
var Lizard = require('../../sub/lizard');
var DB;
var DIC;
var ROOM;

exports.init = function(_DB, _DIC, _ROOM){
DB = _DB;
DIC = _DIC;
ROOM = _ROOM;
};
exports.getTitle = function(){
var R = new Lizard.Tail();
var my = this;

return R;
};
exports.roundReady = function(){
var my = this;

};
exports.turnStart = function(){
var my = this;

};
exports.turnEnd = function(){
var my = this;

};
exports.submit = function(client, text, data){
var my = this;

};
exports.getScore = function(text, delay){
var my = this;



return 0;
};
Loading

0 comments on commit 327e26e

Please sign in to comment.