Skip to content

Lucia Architecture是一个支持Linux和MacOS的轻量级的服务器。目前已完成:静态资源服务器(Lucia Server)。更新中...

Notifications You must be signed in to change notification settings

lsummer/LuciaArchitecture

Repository files navigation

Lucia Architecture

Lucia Server是一个支持Linux和MacOS的轻量级的静态资源服务器。基于C++11多进程(1个master进程+多个worker进程)+多线程(Thread Pool)的架构方式,epoll(LT)+kqueue的reactor模式的多路复用技术,完成了在HTTP1.1协议下的对静态资源的请求与响应。主要包含以下几个模块:

- 读取配置文件模块
- 基于log4cpp的日志模块
- 信号处理模块
- 进程管理模块
- 线程池模块
- 数据池模块
- http解析和响应模块

系统微架构

Atchitecture

开始使用

Lucia Server 可以运行在linuxmacOS环境下,已在Ubuntu 18.04.1 LTSUbuntu 14.04.5 LTSmacOS High Sierra v10.13.3下测试通过。

下载

git clone https://github.com/lsummer/LuciaArchitecture

安装库

log4cpp 安装完成后需要将include和lib位置放入到.bashrc中

# 临时执行
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/Cellar/log4cpp/1.1.3/include
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/Cellar/log4cpp/1.1.3/lib

运行

cd build
cmake ..
make
./bin/lucia

命令

# 仅供推荐使用

# 查看进程信息
MacOS:  ps -eo pid,ppid,tty,pgid,stat,comm |grep -E 'PID|lucia|zsh'
Linux:  ps -eo pid,ppid,tty,sid,stat,command |grep -E 'PID|lucia'

# 结束进程
sudo kill -9 -[pgid|sid]

# 查看日志
tail -f -n100 ./Log/error.log     # 系统启动运行日志
tail -f -n100 ./Log/access.log    # 业务处理(http请求)日志

# 追踪进程系统调用
MacOS: sudo dtruss -p [pid]
Linux: sudo strace -p [pid]

# GDB 真正debug有用的命令
gdb

配置

配置文件地址:./config, 主要包含两个配置文件:log4cpp.propertieslucia.conf,其中log4cpp.properties为日志系统的配置文件,lucia.conf为服务器启动的相关配置文件。

  • log4cpp.properties的编写规则见 链接,推荐使用默认配置

  • lucia.conf的编写规则如下:

# // 描述: 配置文件解析说明
    # // 1. 以 "#" 开头的行作为注释
    # // 2. 以 "[" 开头的行作为注释
    # // 3. 以 "{" 开头的行作为注释
    # // 4. 以 "}" 开头的行作为注释
    # // 5. 每一行前后空格会被忽略
    # // 6. 空行会被忽略
    # // 7. 参数设置格式为: 设置名=参数 
    # // 8. 参数行后面的 "#" 之后的作为注释
    # // 9. '\#' 代表 #
    # // 10. location 开头的表示一个静态资源映射地址
    # //     10.1 ~* 执行正则匹配,但不区分大小写 (四元组) location ~* pattern path
    # //     10.2 = 执行完全匹配 (四元组) location = pattern path
    # //     10.3 / 所有匹配  (三元组) location / path

备注

待解决的问题:

- 进程重启,datapoll里面的数据可能会丢失掉,所以要有两种重启的方式,暴力重启和温和重启。
- 惊群效应
- 线程资源池的回收再利用需要延迟吗?需要考虑一下
- Http 中的request和response的cookie

参考文献

About

Lucia Architecture是一个支持Linux和MacOS的轻量级的服务器。目前已完成:静态资源服务器(Lucia Server)。更新中...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published