2023-05-11 17:21:52 +05:45
|
|
|
package wrapper
|
|
|
|
|
|
|
|
|
|
import (
|
2023-07-12 11:32:03 +05:45
|
|
|
"fmt"
|
2023-05-11 17:21:52 +05:45
|
|
|
"net/http"
|
|
|
|
|
"ociswrapper/common"
|
2023-07-12 11:32:03 +05:45
|
|
|
"ociswrapper/log"
|
2023-05-11 17:21:52 +05:45
|
|
|
"ociswrapper/ocis/config"
|
|
|
|
|
"ociswrapper/wrapper/handlers"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Start(port string) {
|
|
|
|
|
defer common.Wg.Done()
|
|
|
|
|
|
|
|
|
|
if port == "" {
|
|
|
|
|
port = config.Get("port")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
httpServer := &http.Server{
|
|
|
|
|
Addr: ":" + port,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var mux = http.NewServeMux()
|
|
|
|
|
mux.HandleFunc("/", http.NotFound)
|
|
|
|
|
mux.HandleFunc("/config", handlers.SetEnvHandler)
|
2025-08-04 14:31:30 +05:45
|
|
|
mux.HandleFunc("/k8s/config", handlers.K8sSetEnvHandler)
|
|
|
|
|
mux.HandleFunc("/k8s/rollback", handlers.K8sRollbackHandler)
|
2023-05-11 17:21:52 +05:45
|
|
|
mux.HandleFunc("/rollback", handlers.RollbackHandler)
|
2024-07-05 12:54:42 +05:45
|
|
|
mux.HandleFunc("/command", handlers.CommandHandler)
|
|
|
|
|
mux.HandleFunc("/stop", handlers.StopOcisHandler)
|
2024-07-05 15:08:45 +05:45
|
|
|
mux.HandleFunc("/start", handlers.StartOcisHandler)
|
2024-12-12 15:57:43 +05:45
|
|
|
mux.HandleFunc("/services/{service}", handlers.OcisServiceHandler)
|
2025-03-06 17:08:54 +05:45
|
|
|
mux.HandleFunc("/services/rollback", handlers.RollbackServicesHandler)
|
2023-05-11 17:21:52 +05:45
|
|
|
|
|
|
|
|
httpServer.Handler = mux
|
|
|
|
|
|
2023-07-12 11:32:03 +05:45
|
|
|
log.Println(fmt.Sprintf("Starting ociswrapper on port %s...", port))
|
2023-05-11 17:21:52 +05:45
|
|
|
|
|
|
|
|
err := httpServer.ListenAndServe()
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Panic(err)
|
|
|
|
|
}
|
|
|
|
|
}
|