Skip to content

Conversation

@frnsys
Copy link
Contributor

@frnsys frnsys commented Nov 14, 2025

add exit_on_error option when starting server to choose if the entire process exits if the server fails to start

Description

Added exit_on_error as an additional argument to run_server_on_rt. When set to true this exits the entire process if the server fails to start (the current behavior). When set to false the error is propagated to the caller of run_server_on_rt. run_standalone and run_as_service don't expose this parameter, passing true to keep the current behavior.

Related Issue

Motivation and Context

I'm using static-web-server as a library and found it killed my entire program when it failed to start, but I need a more graceful exit (clean up, etc).

How Has This Been Tested?

I ran cargo test and all tests passed. This was on Linux.

Screenshots (if appropriate):

entire process exits if the server fails to start
@semanticdiff-com
Copy link

semanticdiff-com bot commented Nov 14, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  src/server.rs  61% smaller

@joseluisq joseluisq changed the title feat: add exit_on_error option Add exit_on_error option Nov 14, 2025
@joseluisq joseluisq added enhancement New feature or request library Related to the static-web-server crate labels Nov 14, 2025
Copy link
Collaborator

@joseluisq joseluisq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, just a small update to make and fix formatting.

@joseluisq joseluisq changed the title Add exit_on_error option Add exit_on_error option for Server::run_server_on_rt Nov 14, 2025
Co-authored-by: Jose Quintana <[email protected]>
Copy link
Collaborator

@joseluisq joseluisq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are formatting issues. Fix them by applying cargo fmt.

Copy link
Collaborator

@joseluisq joseluisq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@joseluisq joseluisq merged commit 326abbe into static-web-server:master Nov 15, 2025
36 checks passed
@joseluisq joseluisq added this to the v2.40.0 milestone Nov 15, 2025
@joseluisq joseluisq added the v2 v2 release label Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request library Related to the static-web-server crate v2 v2 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants