# Tractors **Repository Path**: SnailCoder/tractors ## Basic Information - **Project Name**: Tractors - **Description**: 使用Rust编写的一个简单的http服务引擎 支持线程池,GET/POST方法解析 - **Primary Language**: Rust - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2023-10-12 - **Last Updated**: 2025-03-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: Rust, 线程池, HTTP服务器 ## README # 注意:这不是一个lib!!! 它是一个bin,一个练习!!! # Tractors #### 目的 对基础知识的练习与实践 #### 介绍 一个简单的http服务引擎。 使用线程池同时处理多个请求 - 当前不支持https,只能使用http。 ### 关于默认参数配置: 如果不使用如何参数或配置,默认访问路径:(http://127.0.0.1:8080)[http://127.0.0.1:8080] #### 如何使用启动参数 指定启动参数命令格式: ``` ./Tractors 命令=值 命令=值 命令=值... ``` #### 如何使用配置文件 - 配置文件名必须为: tractor.conf - 配置文件中参数配置格式: 参数=值。 每一行允许配置一个参数。 - 默认参数文件路径在 Tractors文件同级目录 - 可以在启动参数中指定配置文件路径,建议使用绝对路径。 不需要指定文件名称 ``` ./Tractors configFile=/root/tractors/conf ```` #### 可配置的参数 ##### Server 相关 - host 主机名称 - port 端口号 ##### threadpool 相关 - max_thread_num, 默认cup的核心数量+1 - core_thread_num, 默认值2 - max_task_num, 默认值1024 - thread_keep_alive_time, 默认值 60s ### 注意 这是一个粗糙的应用,不要用于生产环境 ### 进程 - 完成了Get方法解析 2023-10-15 - 完成Post方法解析 2023-10-20 - ThreadPool粗糙版 2023-11-30 - 完善线程池, 添加辅助线程处理请求 2023-12-13 - 完成线程池 2023-12-20 ### 线程池工作原理 TBC ### 知识点: - http协议 - 多线程/线程池, threadpool - 网络编程, request,server - 文件读取,输入参数读取, config - aync 消息发送,接收, mpsc::Sender/Receiver - Metux - Box, Arc - struct, enum, fn, Copy, match... - trait - cargo package