Use common httpserver across fission (#2409)
* Defining httpserver package to capture httpserver shutdown and introduces uniform running of http server across codebase. * Add unit tests for httpserver Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
+4
-6
@@ -34,6 +34,7 @@ import (
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
"github.com/fission/fission/pkg/executor/client"
|
||||
"github.com/fission/fission/pkg/utils/httpserver"
|
||||
"github.com/fission/fission/pkg/utils/metrics"
|
||||
otelUtils "github.com/fission/fission/pkg/utils/otel"
|
||||
)
|
||||
@@ -262,10 +263,7 @@ func (executor *Executor) GetHandler() http.Handler {
|
||||
}
|
||||
|
||||
// Serve starts an HTTP server.
|
||||
func (executor *Executor) Serve(port int, openTracingEnabled bool) {
|
||||
executor.logger.Info("starting executor API", zap.Int("port", port))
|
||||
address := fmt.Sprintf(":%v", port)
|
||||
|
||||
func (executor *Executor) Serve(ctx context.Context, port int, openTracingEnabled bool) {
|
||||
var handler http.Handler
|
||||
if openTracingEnabled {
|
||||
handler = &ochttp.Handler{Handler: executor.GetHandler()}
|
||||
@@ -273,6 +271,6 @@ func (executor *Executor) Serve(port int, openTracingEnabled bool) {
|
||||
handler = otelUtils.GetHandlerWithOTEL(executor.GetHandler(), "fission-executor", otelUtils.UrlsToIgnore("/healthz"))
|
||||
}
|
||||
|
||||
err := http.ListenAndServe(address, handler)
|
||||
executor.logger.Fatal("done listening", zap.Error(err))
|
||||
httpserver.StartServer(ctx, executor.logger, "executor", fmt.Sprintf("%d", port), handler)
|
||||
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ func StartExecutor(ctx context.Context, logger *zap.Logger, functionNamespace st
|
||||
}
|
||||
go reaper.CleanupRoleBindings(ctx, logger, kubernetesClient, fissionClient, functionNamespace, envBuilderNamespace, time.Minute*30)
|
||||
go metrics.ServeMetrics(ctx, logger)
|
||||
go api.Serve(port, openTracingEnabled)
|
||||
go api.Serve(ctx, port, openTracingEnabled)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user