server

package
v0.0.0-...-b4f7333 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2022 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use:   "server",
	Short: "Server that accepts and assigns jobs to workers",

	Run: func(cmd *cobra.Command, args []string) {
		log := viper.Get("logger").(zerolog.Logger)

		m := server.NewMetricsStore()
		runtime := server.NewRuntime(m, log, viper.GetInt("peltr.port"))

		err := runtime.Listen()
		if err != nil {
			log.Fatal().Err(err).Msg("Error listening on server port")
			return
		}
		defer runtime.Close()

		go runtime.HandleConnections()
		go runtime.ControlLoop()

		http.HandleFunc("/workers", runtime.HandleListWorkers)
		http.HandleFunc("/jobs", runtime.HandleListJobQueue)
		http.HandleFunc("/job", runtime.HandleJob)
		http.Handle("/metrics", promhttp.Handler())
		http.ListenAndServe(fmt.Sprintf(":%d", viper.GetInt("peltr.prom-http")), nil)

	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL