component.go 909 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package cherryGops
  2. import (
  3. cherryFacade "github.com/cherry-game/cherry/facade"
  4. clog "github.com/cherry-game/cherry/logger"
  5. "github.com/google/gops/agent"
  6. )
  7. // Component gops 监听进程数据
  8. type Component struct {
  9. cherryFacade.Component
  10. options agent.Options
  11. }
  12. func New(options ...agent.Options) *Component {
  13. component := &Component{}
  14. if len(options) > 0 {
  15. component.options = options[0]
  16. }
  17. return component
  18. }
  19. func (c *Component) Name() string {
  20. return "gops_component"
  21. }
  22. func (c *Component) Init() {
  23. if err := agent.Listen(c.options); err != nil {
  24. clog.Error(err)
  25. }
  26. }
  27. func (c *Component) OnAfterInit() {
  28. }
  29. func (c *Component) OnStop() {
  30. //agent.Close()
  31. }
  32. func TestLoad() {
  33. if err := agent.Listen(agent.Options{
  34. Addr: "",
  35. ConfigDir: "",
  36. ShutdownCleanup: false,
  37. ReuseSocketAddrAndPort: false,
  38. }); err != nil {
  39. clog.Error(err)
  40. }
  41. }