mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
add tracing feature for package gproc (#1923)
This commit is contained in:
25
example/trace/processes/gcmd/main.go
Normal file
25
example/trace/processes/gcmd/main.go
Normal file
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gcmd"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/os/gproc"
|
||||
)
|
||||
|
||||
var (
|
||||
Main = &gcmd.Command{
|
||||
Name: "main",
|
||||
Brief: "main process",
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||
g.Log().Debug(ctx, `this is main process`)
|
||||
return gproc.ShellRun(ctx, `go run sub/sub.go`)
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func main() {
|
||||
Main.Run(gctx.New())
|
||||
}
|
||||
24
example/trace/processes/gcmd/sub/sub.go
Normal file
24
example/trace/processes/gcmd/sub/sub.go
Normal file
@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gcmd"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
)
|
||||
|
||||
var (
|
||||
Sub = &gcmd.Command{
|
||||
Name: "sub",
|
||||
Brief: "sub process",
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
|
||||
g.Log().Debug(ctx, `this is sub process`)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func main() {
|
||||
Sub.Run(gctx.New())
|
||||
}
|
||||
Reference in New Issue
Block a user