shutdown

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2020 License: MIT, MIT Imports: 3 Imported by: 0

README

Shutdown

Shutdown the application with a signal.

Install & Build

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

Usage

package main

import (
 "fmt"
 "github.com/lishimeng/go-libs/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 Exit added in v0.0.7

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