openresty-redis,


安装

install_xxx.sh

#!/bin/bash


REDIS_VAR=2.8.18#版本号

BUILD_DIR=/tmp/install_k7server#下载目录

DEST_DIR=/opt/k7server#安装目录


# install jemalloc#用于动态内存管理


cd $BUILD_DIR

wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2

tar -jxvf jemalloc-3.6.0.tar.bz2

cd jemalloc-3.6.0

./configure

make && make install



# install redis

wget http://download.redis.io/releases/redis-$REDIS_VAR.tar.gz

tar zxf redis-$REDIS_VAR.tar.gz

cd redis-$REDIS_VAR

make

cp src/redis-server $DEST_DIR/redis/bin

cp src/redis-cli $DEST_DIR/redis/bin

cp src/redis-sentinel $DEST_DIR/redis/bin

cp src/redis-benchmark $DEST_DIR/redis/bin

cp src/redis-check-aof $DEST_DIR/redis/bin

cp src/redis-check-dump $DEST_DIR/redis/bin

cp redis.conf $DEST_DIR/conf



# install openresty

cd $BUILD_DIR

wget http://openresty.org/download/ngx_openresty-$OPENRESTY_VER.tar.gz

tar zxf ngx_openresty-$OPENRESTY_VER.tar.gz

cd ngx_openresty-$OPENRESTY_VER


./configure --prefix=$DEST_DIR/openresty --with-luajit

make

make install

参考
openresty(nginx+lua)安装
redis安装

我对我们游戏服务器的理解

以注册为例
注册的http请求为:http:x.x.x.x:xxxx/lua?json={“mid”:0,”action”:”Reg.reg”,”usr”:”T0.404193805559”,”pwd”:”123”,”pTyp”:”ios”,”ver”:1.1101}


请求被nginx收到并处理(通过content_by_lua_file 指定content阶段的处理文件即content.lua)
content.lua是require了config.lua和HttpServerApp.lua的处理逻辑入口,HttpServerApp.lua又包含和继承了其他的lua文件和类,从而对用户的不同请求做出不同的响应。
有效的请求最终会跳转到对应的xxxAction里对应的方法,并根据用户请求中的数据进行一系列的判断,必要时将通过RedisEasy.lua和Redis数据库进行数据交互。(RedisEasy是包含并封装好了一些和Redis数据库交互指令的类)

下图是从content到xxxAction跳转的流程

相关内容

    暂无相关文章