Code Monkey home page Code Monkey logo

lightwebserver's Introduction

lightwebserver

This project is to provide the learning of webserver for those who know none of it.
Thanks very much for tinywebserver(https://github.com/qinguoyi/TinyWebServer.git)

目录

1、配置基础环境

2、压力测试

3、线程池

4、锁

5、数据库连接

6、定时器

7、http连接

8、日志

9、服务器

编译及运行

  • 测试前确认已安装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

    make server
  • 启动server

    ./server
  • 浏览器端

    ip:9006
  • 清除编译

    make clean

运行

个性化运行


./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模型

lightwebserver's People

Contributors

gaopijian 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.