-
-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Respect start timeout setting and expose exception from server startup #117
Conversation
evanlwj
commented
Apr 4, 2018
- Respect the start timeout setting
- Expose error(exception) from server startup
- To be more efficient in waiting server startup
Codecov Report
@@ Coverage Diff @@
## master #117 +/- ##
==========================================
- Coverage 66.73% 66.56% -0.18%
==========================================
Files 79 79
Lines 2853 2862 +9
Branches 387 389 +2
==========================================
+ Hits 1904 1905 +1
- Misses 733 742 +9
+ Partials 216 215 -1
Continue to review full report at Codecov.
|
{ | ||
// Throw out exception if service start fail | ||
if (_httpServer.RunningException != null) throw new Exception($"Service start failed with error: {_httpServer.RunningException.Message}", _httpServer.RunningException); | ||
// Repsect start timeout setting by throwing TimeoutException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Respect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -29,6 +30,11 @@ interface IOwinSelfHost | |||
/// </value> | |||
List<int> Ports { get; } | |||
|
|||
/// <summary> | |||
/// Determind an exception occurred in host running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exception occurred when the host is running
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks
{ | ||
server.Dispose(); | ||
IsStarted = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No foreach (var server in servers)
is needed in the finally section ???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foreach (var server in servers) is moved into finally block. The reason of moving disposing server in finally is to make sure allocated resources(like handles in kernel mode) to be cleaned up immediately rather than wait until application is terminated.
// Dispose all servers in finally block to make sure clean up allocated resource on error happening
servers.ForEach((s) => s.Dispose());
// Throw out exception if service start fail | ||
if (_httpServer.RunningException != null) throw new Exception($"Service start failed with error: {_httpServer.RunningException.Message}", _httpServer.RunningException); | ||
// Repsect start timeout setting by throwing TimeoutException | ||
if (ctsStartTimeout.IsCancellationRequested) throw new TimeoutException($"Service start timed out after {TimeSpan.FromMilliseconds(settings.StartTimeout)}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place throw new ...
on new line with {
and }
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done same
while (!_httpServer.IsStarted) | ||
{ | ||
// Throw out exception if service start fail | ||
if (_httpServer.RunningException != null) throw new Exception($"Service start failed with error: {_httpServer.RunningException.Message}", _httpServer.RunningException); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place throw new ...
on new line with {
and }
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks