Files
flux/cmd/daemon/main.go
Zoe c51eca5dab Expand logging, and daemonless command support.
This adds more logging in certain places, and adds logging to the CLI.
It also allows for certain commands in the CLI to be used without a
daemon connection, namely `init`, which previously required the daemon
to be connected, but now does not since it doesnt need it.
2025-05-08 09:53:41 -05:00

37 lines
971 B
Go

package main
import (
"fmt"
"net/http"
_ "net/http/pprof"
"os"
"github.com/juls0730/flux/internal/handlers"
)
func main() {
fluxServer := handlers.NewServer()
defer fluxServer.Stop()
http.HandleFunc("POST /deploy", fluxServer.DeployNewApp)
http.HandleFunc("GET /apps", fluxServer.GetAllApps)
http.HandleFunc("GET /app/by-name/{name}", fluxServer.GetAppByName)
http.HandleFunc("GET /app/by-id/{id}", fluxServer.GetAppById)
// a PUT request is the proper type to use since these endpoints are idempotent
http.HandleFunc("PUT /app/{id}/start", fluxServer.StartApp)
http.HandleFunc("PUT /app/{id}/stop", fluxServer.StopApp)
http.HandleFunc("DELETE /apps", fluxServer.DeleteAllDeploymentsHandler)
http.HandleFunc("DELETE /app/{id}", fluxServer.DeleteDeployHandler)
http.HandleFunc("GET /heartbeat", fluxServer.DaemonInfoHandler)
err := fluxServer.ListenAndServe()
if err != nil {
fmt.Printf("Failed to start server: %v\n", err)
os.Exit(1)
}
}