골롱두지주
https://github.com/dwg255/landlord
설명:go modules 관리 의존 패키지, 컴파일 자동 다운로드 의존 실행;sqlite 데이터베이스를 사용하면 설정할 필요가 없습니다.스스로 무뇌출패 AI를 가지고 있다.서비스 측은 압력 테스트를 거쳤고 클라이언트 코드는https://github.com/mailgyc/doudizhu, 원본 서버는python tornado로 개발됩니다.Golang이 개발한 서비스 사이드 프로그래밍은 간단하고 실행이 효율적이며 다중 핵 자원을 효과적으로 이용한다. 게임 서버 사이드는 Golang의 전형적인 응용 장면 중 하나이다.프로젝트는goroutine와channel을 대량으로 사용하여 이름과 주석이 명확합니다.
기본 종속 패키지:
* 、 、 *
* 、 、 、 *
* http *
*sqlite *
* 、 *
* 、 、 、 *
func init() { // pid , pid
pidFileName := "pid"
fileInfo, err := os.Stat(pidFileName)
if err != nil {
if os.IsNotExist(err) {
err = os.Mkdir(pidFileName, os.ModePerm)
fileInfo, _ = os.Stat(pidFileName)
}
}
if fileInfo.IsDir() {
pid := os.Getpid()
pidFile, err := os.OpenFile(pidFileName+"/landlord.pid", os.O_RDWR|os.O_CREATE, 0766)
if err != nil {
logs.Error("open pidFile [%s] error :%v", pidFileName, err)
return
}
err = pidFile.Truncate(0) //
_, err = io.WriteString(pidFile, strconv.Itoa(pid))
if err != nil {
logs.Error("write pid error :%v", err)
}
err = pidFile.Close()
if err != nil {
logs.Error("close pid file err: %v", err)
}
} else {
logs.Error("pidFile [%s] is exists and not dir", pidFileName)
}
}
* 추가 코드는 GitHub * -service-room을 참조하십시오.go 파일에는 압력 측정 코드가 포함되어 있으며 5000개의 방의 CPU 평균 점유율은 30%-50%이고 메모리는 200M 정도이다.
실행 단계:
1. 원본 다운로드:
git clone https://github.com/dwg255/landlord.git
2. 컴파일링:
cd landlord/main
go build -o ../main.exe
cd ..
main.exe
3. 시작: 브라우저 액세스http://localhost
4. 효과 표시:http://blzz.shop
5. 캡처 실행:
License
This project is released under the terms of the MIT license. See LICENSE for more information or see https://opensource.org/licenses/MIT.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.