Skip to content

Close server gracefully  #6

@Az107

Description

@Az107

Currently, the hteapot HTTP server is terminated by pressing Ctrl+C, which abruptly stops the process. This method does not allow for a graceful shutdown, potentially leading to:

•	Loss of in-flight requests
•	Incomplete logging
•	Corrupted data

Objective:

Implement a more graceful shutdown process for the hteapot HTTP server. The new shutdown mechanism should:

1.	Allow the server to finish processing ongoing requests.
2.	Close all active connections cleanly.
3.	Perform any necessary cleanup tasks (e.g., flushing logs, saving state).
4.	Notify connected clients about the shutdown if applicable.

Acceptance Criteria:

•	Pressing Ctrl+C should initiate the graceful shutdown process.
•	The server should log a message indicating that the shutdown process has started.
•	All in-flight requests should be completed before the server stops.
•	All resources should be properly released.
•	The process should exit only after all shutdown tasks are completed.

Additional Notes:

•	Consider using signal handling (e.g., SIGTERM) to trigger the graceful shutdown.
•	Ensure that the implementation does not introduce significant delays in the shutdown process.

Reference:

Proper way to close TcpStream

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions