Skip to content

Commit

Permalink
Added automatic vertex building when running the kernel in a dev envi…
Browse files Browse the repository at this point in the history
…ronment
  • Loading branch information
quentinguidee committed Sep 26, 2023
1 parent c2f3694 commit e87d28f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions kernel/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ func runVertex(user *user.User) (*exec.Cmd, error) {
vlog.Int("gid", gid),
)

// If vertex init.go is there, build vertex first.
_, err = os.Stat("init.go")
if err == nil {
log.Info("init.go found. Building vertex...")
buildVertex()
}

cmd := exec.Command("./vertex")
cmd.SysProcAttr = &syscall.SysProcAttr{}
cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uint32(uid), Gid: uint32(gid)}
Expand All @@ -106,3 +113,15 @@ func runVertex(user *user.User) (*exec.Cmd, error) {

return cmd, cmd.Start()
}

func buildVertex() {
log.Info("Building vertex")
cmd := exec.Command("go", "build", "-o", "vertex", "init.go")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if err != nil {
log.Error(err)
os.Exit(1)
}
}

0 comments on commit e87d28f

Please sign in to comment.