Files
server/main.go
T
restitux bbe9dcaf2a WIP: Replace job execution with runner delegation
Server now accepts runner connections via websockets. Jobs
will be delegated to these runners. This is currently a WIP,
as it is still hardcoded to use the first available runner.
2022-10-16 14:54:49 -06:00

39 lines
1.0 KiB
Go

package main
import (
"git.ohea.xyz/cursorius/server/config"
"git.ohea.xyz/cursorius/server/jobscheduler"
"git.ohea.xyz/cursorius/server/listen"
"github.com/op/go-logging"
"os"
)
var log = logging.MustGetLogger("cursorius-server")
func main() {
var format = logging.MustStringFormatter(
`%{color}%{time:15:04:05.000} %{level:.4s}:%{color:reset} %{message}`,
)
backend := logging.NewLogBackend(os.Stderr, "", 0)
backendFormatter := logging.NewBackendFormatter(backend, format)
backendLeveled := logging.AddModuleLevel(backendFormatter)
backendLeveled.SetLevel(logging.DEBUG, "")
logging.SetBackend(backendLeveled)
log.Info("Starting cursorius-server")
configData, err := config.GetConfig()
if err != nil {
log.Errorf("Could not get configuration: %v", err)
}
runCh, registerCh, err := jobscheduler.StartJobScheduler(configData.Config.Jobs, configData.Config.Runners)
if err != nil {
log.Errorf("Could not start runner: %v", err)
}
listen.Listen(configData.Config.Address, configData.Config.Port, runCh, registerCh)
}