Skip to content
abfermPublic

About

Golang port of downtimed

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

downtime

Golang port of downtimed

Examples

Track system downtime

	ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
	defer cancel()

	daemon := downtime.NewDaemon(store, db, sleepDuration)

	boottime, err := downtime.SystemBootTime()
	if err != nil {
		logger.Criticalf(err.Error())
		return err
	}
	err = daemon.Init(boottime, goTimeFormat)
	if err != nil {
		logger.Criticalf("init failed: %s", err.Error())
		return err
	}

	err = daemon.Run(ctx)
	if errors.Is(err, context.Canceled) {
		return nil
	}

Track program downtime

	ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
	defer cancel()

	daemon := downtime.NewDaemon(store, db, sleepDuration)

	boottime := downtime.ProcessBootTime()
	err = daemon.Init(boottime, goTimeFormat)
	if err != nil {
		logger.Criticalf("init failed: %s", err.Error())
		return err
	}

    go func(){
        err = daemon.Run(ctx)
        if errors.Is(err, context.Canceled) {
            return nil
        } else if err != nil{
            panic(err)
        }
    }

About

Golang port of downtimed

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

⌂ 换网址