Code Monkey home page Code Monkey logo

c_game's Introduction

golang-websocket-framework

数据库ORM: github.com/xorm

Redis: github.com/garyburd/redigo/redis

配置文件: github.com/Unknwon/goconfig

日志: github.com/Sirupsen/logrus

websocket: github.com/gorilla/websocket

协议仿 jsonrpc

go get -u github.com/fhbzyc/c_game

cd $GOPATH/github.com/fhbzyc/c_game

go build

./c_game

windows 下不可用 因为有用 github.com/facebookgo/grace/gracehttp 实现优雅重启

或用:

package main

import ( 
    "github.com/Unknwon/goconfig"
    "github.com/fhbzyc/c_game/handler"
    "log"
    "net/http"
    _ "net/http/pprof"     
    "runtime" 
)

func main() {

    runtime.GOMAXPROCS(runtime.NumCPU())

    c, err := goconfig.LoadConfigFile("conf/conf.ini")
    if err != nil {
        log.Println(err)
    }

    port, err := c.GetValue("Server", "port")
    if err != nil {
        log.Println(err)
    }

    // websocket
    http.Handle("/ws", handler.Handler{})

    server := new(http.Server)
    server.Addr = ":" + port

    if err = Serve(server); err != nil {
        log.Println(err)
    }
}

func Serve(server *http.Server) error {
    return http.ListenAndServe(server.Addr, server.Handler)
}

覆盖main.go

c_game's People

Contributors

joshua86z avatar

Watchers

欧阳大哥 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.