shutdown

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2020 License: MIT Imports: 4 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go Application Shutdown

Shutdown the application with a signal.

Install & Build

go get github.com/lishimeng/go-app-shutdown.git

Usage

package main

import (
 "fmt"
 "github.com/lishimeng/go-app-shutdown"
 "time"
)

func main() {
    go work()
    shutdown.WaitExit(&shutdown.Configuration{
        BeforeExit: func(s string) {
            fmt.Printf("Shutdown %s\n", s)
        },
    })
}

func work() {
    for{
        time.Sleep(time.Second * 3)
        fmt.Println("work....")
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Context

func Context() context.Context

func Exit

func Exit(msg string)

func WaitExit

func WaitExit(config *Configuration)

Types

type Configuration

type Configuration struct {
	BeforeExit func(string)
	Signals    []os.Signal
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址