yhirose/cpp-httplib

Improvements in docker/main.cc

bhavya2021245 opened this issue · 3 comments

Improvements in file main.cc
1.Multithreading Implementation (Handle More Requests Concurrently)
BENEFIT:-The use of a thread pool allows the server to handle multiple requests simultaneously, making it scalable for high traffic. It
utilizes the system’s CPU cores more efficiently, reducing response times under load.

2.Make base_dir, host, and port Configurable via Command-Line Arguments
BENEFIT:-This makes the server more flexible and reusable across different environments. You no longer need to modify the source code to change the host, port, or directory path from which files are served. This approach supports easy deployment and configuration in different environments.

3.Proper Error Handling and Logging in svr.listen()
BENEFIT:-Proper error logging helps you debug server startup issues (like when a port is already in use). Instead of just failing silently or returning an uninformative exit code, the server logs an appropriate message, aiding in troubleshooting.

@bhavya2021245 thank you for the suggestions! Since I made this docker image just for my personal use in mind, I only add necessary things for my project. But you are welcome to make the suggestions and send a pull request!

Hi @yhirose I have created a pull request for this.

Please see my comment in your pull request. Thanks!