//Basic usage example.
func Example() {
	// Create healthchecker
	checker := healthcheck.New(time.Millisecond)

	// Register HealthIndicator
	checker.RegisterIndicator(&SimpleHttpAliveIndicator{})

	// Add hooks that consume the results.
	checker.AddHook("testHook", SimpleLogHook)

	// Start the checker
	checker.Start()
	time.Sleep(10 * time.Second)

	// Before the application finish try
	// to gracefully shutdown the checker
	checker.Stop()
}
Ejemplo n.º 2
0
	engine             = gin.Default()
	mongo  DataStorage = &Mongo{
		Database:             "plag",
		AssignmentCollection: "assignments",
		SubmissionCollection: "submissions",
		ResultCollection:     "results",
	}
	cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
	//Log is Global logger
	Log = log.StandardLogger()
	//Apac is config for apac
	Apac ApacConfig

	//expvar
	metrics       *Metrics
	healthChecker = healthcheck.New(time.Minute)
)

func main() {

	flag.Parse()
	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			fmt.Println("Error: ", err)
		}
		//runtime.SetCPUProfileRate(100)
		err = pprof.StartCPUProfile(f)
		if err != nil {
			fmt.Println("Error: ", err)
		}