wip: process management

This commit is contained in:
2023-08-31 08:05:20 +10:00
parent 9cbdbebee5
commit 92f7873f98
11 changed files with 733 additions and 11 deletions

9
daemon/daemon.go Normal file
View File

@@ -0,0 +1,9 @@
package daemon
import "github.com/spf13/cobra"
func Start(cmd *cobra.Command, args []string) error {
_, _ = cmd, args // prevent warnings for unused arguments
return nil
}

23
daemon/process.go Normal file
View File

@@ -0,0 +1,23 @@
package daemon
import (
"fmt"
"os/exec"
)
type ProcessConfig interface {
Name() string
Args() []string
Env() map[string]string
Dir() string
}
func StartProcess(config ProcessConfig) error {
cmd := exec.Command(config.Name(), config.Args()...)
for k, v := range config.Env() {
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", k, v))
}
cmd.Dir = config.Dir()
return nil
}

4
daemon/process_unix.go Normal file
View File

@@ -0,0 +1,4 @@
package daemon
func DetectDeadChildProcess() {
}