fetch_ml/internal/scheduler/service_manager_unix.go
Jeremie Fraeys 43e6446587
feat(scheduler): implement multi-tenant job scheduler with gang scheduling
Add new scheduler component for distributed ML workload orchestration:
- Hub-based coordination for multi-worker clusters
- Pacing controller for rate limiting job submissions
- Priority queue with preemption support
- Port allocator for dynamic service discovery
- Protocol handlers for worker-scheduler communication
- Service manager with OS-specific implementations
- Connection management and state persistence
- Template system for service deployment

Includes comprehensive test suite:
- Unit tests for all core components
- Integration tests for distributed scenarios
- Benchmark tests for performance validation
- Mock fixtures for isolated testing

Refs: scheduler-architecture.md
2026-02-26 12:03:23 -05:00

34 lines
862 B
Go

//go:build !windows
// +build !windows
package scheduler
import (
"os/exec"
"syscall"
)
// setProcessGroup sets up process group for clean termination on Unix systems
func setProcessGroup(cmd *exec.Cmd) {
if cmd.SysProcAttr == nil {
cmd.SysProcAttr = &syscall.SysProcAttr{}
}
cmd.SysProcAttr.Setpgid = true
}
// killProcessGroup kills the entire process group on Unix systems
func killProcessGroup(cmd *exec.Cmd) {
if cmd != nil && cmd.Process != nil {
// Negative PID kills the entire process group
_ = syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
}
}
// isProcessRunning checks if a process is still running on Unix systems
func isProcessRunning(cmd *exec.Cmd) bool {
if cmd == nil || cmd.Process == nil {
return false
}
// Signal 0 is a no-op that just checks if process exists
return cmd.Process.Signal(syscall.Signal(0)) == nil
}