main.go 870 字节
Newer Older
H
agent  
heyanlong 已提交
1 2 3
package main

import (
H
heyanlong 已提交
4
	"agent/agent/logger"
H
agent  
heyanlong 已提交
5
	"agent/agent/service"
H
heyanlong 已提交
6
	cli "github.com/urfave/cli/v2"
H
agent  
heyanlong 已提交
7 8 9
	"os"
)

H
heyanlong 已提交
10 11
var log = logger.Log

H
agent  
heyanlong 已提交
12
func main() {
H
heyanlong 已提交
13 14 15 16 17 18 19

	defer func() {
		if err := recover(); err != nil {
			log.Error(err)
		}
	}()

H
heyanlong 已提交
20 21 22
	app := cli.NewApp()
	app.Name = "sky_php_agent"
	app.Usage = "the skywalking trace sending agent"
H
heyanlong 已提交
23
	app.Version = "3.2.7"
H
heyanlong 已提交
24
	app.Flags = []cli.Flag{
H
heyanlong 已提交
25
		&cli.StringSliceFlag{Name: "grpc", Usage: "SkyWalking collector grpc address", Value: cli.NewStringSlice("127.0.0.1:11800")},
H
heyanlong 已提交
26 27
		&cli.StringFlag{Name: "socket", Usage: "Pipeline for communicating with PHP", Value: "/var/run/sky-agent.sock"},
		&cli.IntFlag{Name: "send-rate", Usage: "Send trace 1 second by default", Value: 1},
H
heyanlong 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40
	}

	app.Action = func(c *cli.Context) error {

		a := service.NewAgent(c)
		a.Run()
		return nil
	}

	err := app.Run(os.Args)
	if err != nil {
		log.Errorln(err)
	}
H
agent  
heyanlong 已提交
41
}