Skip to content

Fresheyeball/death

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Death Build Status

Join the chat at https://gitter.im/vrecan/death

Simple library to make it easier to manage the death of your application.

Get The Library

go get github.com/vrecan/death

Use The Library

package main

import (
	DEATH "github.com/vrecan/death"
	SYS "syscall"
)

func main() {
	death := DEATH.NewDeath(SYS.SIGINT, SYS.SIGTERM) //pass the signals you want to end your application
	//when you want to block for shutdown signals
	death.WaitForDeath() // this will finish when a signal of your type is sent to your application
}

Close Other Objects On Shutdown

One simple feature of death is that it can also close other objects when shutdown starts

``` package main

import ( DEATH "github.com/vrecan/death" SYS "syscall" )

func main() { death := DEATH.NewDeath(SYS.SIGINT, SYS.SIGTERM) //pass the signals you want to end your application objects := make([]DEATH.Closable, 0)

objects = append(objects, &NewType{}) // this will work as long as the type implements a Close method

//when you want to block for shutdown signals
death.WaitForDeath(objects...) // this will finish when a signal of your type is sent to your application

}

type NewType struct { }

func (n *NewType) Close() { }

About

Managing go application shutdown with signals.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%