✅ Queue multi-threading
How to use it is as follows:
pi@centos: ~ /yadihttpd$ ./yadihttpd
usage: ./yadihttpd < port > < websit root > < log dir >
要提前创建好文件夹和响应静态文件
如:./yadihttpd 80 /home/pi/www /home/pi/yadihttpdlog
pi@centos: ~ /yadihttpd$ sudo ./yadihttpd 80 /home/pi/www /home/pi/yadihttpdlog
应设置euid, 如:chmod u+s ./yadihttpdSample Blog Project: Blog File Tree
【Blog Home Page】
Functions completed in version 0.1:
✅ Print logs, read message headers, and log file names are generated based on time
✅epoll version and return the corresponding file
✅ Log queue, automatic switching, log writing alone thread
✅ Large file support
✅ File Reading Permission Limitations
✅ Simple blog
Show specific line number, function, file name
View the log thread:
The log thread generally sleeps (the queue is empty, which means it is not busy, releases the lock, blocks for one second).
? Access the log before link:
? Access the link log:
? When a certain number of log records (such as 5000), the file will be automatically switched.
Image reading
Large file support (may be some bugs)
epollout handles buffers and sets non-blocking fds. The server can handle multiple requests at the same time.
Server file root directory layout
pi@raspberrypi: ~ /www $ tree
.
├── blog # marked转换之后的博客
│ ├── linux_notes.html
│ └── test.html
├── css
│ ├── my.css
│ └── prism.css # 代码高亮等等
├── img
│ ├── 1.jpg
│ ├── eg_tulip.jpg
│ ├── lake.jpg
│ └── log.jpg
├── index.html
├── js
│ └── prism.js # 代码高亮等等
└── md # 初始markdown形式
├── linux_notes.md
├── md2html.sh #批量转换脚本 md->html
├── test.md
└── tmp.mdfileThe library used:
marked: markdown -> html
prismjs: Code highlighting and other layouts
? fd leak investigation
There is something I forgot to close. After testing for a while, as shown in the figure below, there seems to be no problem with FD leak, but there is still an occasional segfault that has not been found yet.
? Segment error check
? url is too long: Thanks for testing the malicious program of my website at night
? url direct access directory error fix, same as above.
One accpet thread, one log thread, and three child threads handle the request, and each core is requested about 1400 per second.