package main
import (
"os"
"time"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/os/gproc"
)
func main() {
var ctx = gctx.New()
if gproc.IsChild() {
g.Log().Printf(ctx, "%d: Hi, I am child, waiting 3 seconds to die", gproc.Pid())
time.Sleep(time.Second)
g.Log().Printf(ctx, "%d: 1", gproc.Pid())
time.Sleep(time.Second)
g.Log().Printf(ctx, "%d: 2", gproc.Pid())
time.Sleep(time.Second)
g.Log().Printf(ctx, "%d: 3", gproc.Pid())
} else {
m := gproc.NewManager()
p := m.NewProcess(os.Args[0], os.Args, os.Environ())
p.Start(ctx)
p.Wait()
g.Log().Printf(ctx, "%d: child died", gproc.Pid())
}
}