Conversation
| RegisterHandler("/foo", "GET", AuthorizationRequiredHandler(authorizedTsuruHandler)) | ||
| defer resetHandlers() | ||
|
|
||
| go RunServer(false) |
There was a problem hiding this comment.
Calling RunServer with false for the dryMode is quite problematic, this is the cause of all the race conditions in the tests and this happens because the test isn't closing the old server and calling shutdown on multiple initialized components. Calling shutdown.Do() before the test exits should be able to fix this. However, I'm not sure if some of our packages can safely handle being reinitialized after a shutdown.
|
|
||
| if httpsSrv != nil { | ||
| if httpSrv != nil { | ||
| go startHttpServer(httpSrv, listen) |
There was a problem hiding this comment.
By starting a goroutine here we are ignoring possible errors during listening. Maybe we should have a channel for errors to capture then, something like:
errCh := make(chan error, 2)
if httpsSrv != nil {
go func() { errCh <- startHttpsServer(httpsSrv, listen, ...) }()
}
if httpSrv != nil {
go func() { errCh <- startHttpServer(httpSrv, listen) }()
}
return <-errCh
Also, I don't think we should call fatal in createServers since we're able to return errors. We should simply return the errors and let the caller call fatal for any returned error.
With this PR, it's possible to start 2 tsuru server instances simultaneously, one with HTTP and the other with HTTPS. The use case for this is when you want to migrate from HTTP to HTTPS, and you need to keep them both running for some time.
To enable HTTP server in port 8080 and HTTPS server in port 8443, for instance, set this in
tsuru.conf:To use only HTTPS, set
use-tls: trueand only one oflisten,tls:listenkeys.