feat(daemon): parallel execution
This commit is contained in:
		| @@ -11,32 +11,15 @@ import ( | ||||
| 	"github.com/rs/zerolog/log" | ||||
|  | ||||
| 	"code.dumpstack.io/tools/out-of-tree/client" | ||||
| 	"code.dumpstack.io/tools/out-of-tree/daemon" | ||||
| ) | ||||
|  | ||||
| type DaemonCmd struct { | ||||
| type daemonCmd struct { | ||||
| 	Addr string `default:":63527"` | ||||
|  | ||||
| 	Serve DaemonServeCmd `cmd:"" help:"start daemon"` | ||||
|  | ||||
| 	Job  DaemonJobCmd  `cmd:"" aliases:"jobs" help:"manage jobs"` | ||||
| 	Repo DaemonRepoCmd `cmd:"" aliases:"repos" help:"manage repositories"` | ||||
| } | ||||
|  | ||||
| type DaemonServeCmd struct{} | ||||
|  | ||||
| func (cmd *DaemonServeCmd) Run(dm *DaemonCmd, g *Globals) (err error) { | ||||
| 	d, err := daemon.Init(g.Config.Kernels) | ||||
| 	if err != nil { | ||||
| 		log.Fatal().Err(err).Msg("") | ||||
| 	} | ||||
| 	defer d.Kill() | ||||
|  | ||||
| 	go d.Daemon() | ||||
| 	d.Listen(dm.Addr) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| type DaemonJobCmd struct { | ||||
| 	List   DaemonJobsListCmd   `cmd:"" help:"list jobs"` | ||||
| 	Status DaemonJobsStatusCmd `cmd:"" help:"show job status"` | ||||
|   | ||||
							
								
								
									
										47
									
								
								cmd/daemon_linux.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								cmd/daemon_linux.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| //go:build linux | ||||
| // +build linux | ||||
|  | ||||
| package cmd | ||||
|  | ||||
| import ( | ||||
| 	"github.com/rs/zerolog/log" | ||||
|  | ||||
| 	"code.dumpstack.io/tools/out-of-tree/daemon" | ||||
| ) | ||||
|  | ||||
| type DaemonCmd struct { | ||||
| 	daemonCmd | ||||
|  | ||||
| 	Threads int `help:"number of threads to use"` | ||||
|  | ||||
| 	OvercommitMemory float64 `help:"overcommit memory factor"` | ||||
| 	OvercommitCPU    float64 `help:"overcommit CPU factor"` | ||||
|  | ||||
| 	Serve DaemonServeCmd `cmd:"" help:"start daemon"` | ||||
| } | ||||
|  | ||||
| type DaemonServeCmd struct{} | ||||
|  | ||||
| func (cmd *DaemonServeCmd) Run(dm *DaemonCmd, g *Globals) (err error) { | ||||
| 	d, err := daemon.Init(g.Config.Kernels) | ||||
| 	if err != nil { | ||||
| 		log.Fatal().Err(err).Msg("") | ||||
| 	} | ||||
| 	defer d.Kill() | ||||
|  | ||||
| 	if dm.Threads > 0 { | ||||
| 		d.Threads = dm.Threads | ||||
| 	} | ||||
|  | ||||
| 	if dm.OvercommitMemory > 0 { | ||||
| 		d.Resources.CPU.SetOvercommit(dm.OvercommitMemory) | ||||
| 	} | ||||
|  | ||||
| 	if dm.OvercommitCPU > 0 { | ||||
| 		d.Resources.CPU.SetOvercommit(dm.OvercommitCPU) | ||||
| 	} | ||||
|  | ||||
| 	go d.Daemon() | ||||
| 	d.Listen(dm.Addr) | ||||
| 	return | ||||
| } | ||||
							
								
								
									
										8
									
								
								cmd/daemon_macos.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								cmd/daemon_macos.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| //go:build darwin | ||||
| // +build darwin | ||||
|  | ||||
| package cmd | ||||
|  | ||||
| type DaemonCmd struct { | ||||
| 	daemonCmd | ||||
| } | ||||
		Reference in New Issue
	
	Block a user