Skip to content

trybesthbk/mytinyweb

Repository files navigation

快速运行

  • 服务器测试环境

    • Ubuntu版本16.04
    • MySQL版本5.7.29
  • 浏览器测试环境

    • Windows、Linux均可
    • Chrome
    • FireFox
    • 其他浏览器暂无测试
  • 测试前确认已安装MySQL数据库

    // 建立yourdb库
    create database yourdb;
    
    // 创建user表
    USE yourdb;
    CREATE TABLE user(
        username char(50) NULL,
        passwd char(50) NULL
    )ENGINE=InnoDB;
    
    // 添加数据
    INSERT INTO user(username, passwd) VALUES('name', 'passwd');
  • 修改main.cpp中的数据库初始化信息

    //数据库登录名,密码,库名
    string user = "root";
    string passwd = "root";
    string databasename = "yourdb";
  • build

    sh ./build.sh
  • 启动server

    ./server
  • 浏览器端

    ip:9006

个性化运行

./server [-p port] [-l LOGWrite] [-m TRIGMode] [-o OPT_LINGER] [-s sql_num] [-t thread_num] [-c close_log] [-a actor_model]
  • -p,自定义端口号
    • 默认9006
  • -l,选择日志写入方式,默认同步写入
    • 0,同步写入
    • 1,异步写入
  • -m,listenfd和connfd的模式组合,默认使用LT + LT
    • 0,表示使用LT + LT
    • 1,表示使用LT + ET
    • 2,表示使用ET + LT
    • 3,表示使用ET + ET
  • -o,优雅关闭连接,默认不使用
    • 0,不使用
    • 1,使用
  • -s,数据库连接数量
    • 默认为8
  • -t,线程数量
    • 默认为8
  • -c,关闭日志,默认打开
    • 0,打开日志
    • 1,关闭日志
  • -a,选择反应堆模型,默认Proactor
    • 0,Proactor模型
    • 1,Reactor模型

测试示例命令与含义

./server -p 9007 -l 1 -m 0 -o 1 -s 10 -t 10 -c 1 -a 1

CGImysql:数据库连接池
http:http报文处理命令
lock:锁机制封装
log:日志模块
root:资源文件夹
test_presure:压测
threadpool:线程池
timer:定时器

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors