ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - vrecan/death: Managing go application shutdown with signals.
Managing go application shutdown with signals. Contribute to vrecan/death development by creating an account on GitHub.
Visit Site

GitHub - vrecan/death: Managing go application shutdown with signals.

GitHub - vrecan/death: Managing go application shutdown with signals.

Death Build Status Coverage Status Go Reference Join the chat at https://gitter.im/vrecan/death

Get The Library

Use gopkg.in to import death based on your logger.

Version Go Get URL source doc Notes
3.x github.com/vrecan/death/v3 source doc This removes the need for an independent logger. By default death will not log but will return an error if all the closers do not properly close. If you want to provide a logger just satisfy the deathlog.Logger interface. This also uses go modules so import it as github.com/vrecan/death/v3
2.x gopkg.in/vrecan/death.v2 source doc This supports loggers who do not return an error from their Error and Warn functions like logrus
1.x gopkg.in/vrecan/death.v1 souce doc This supports loggers who do return an error from their Error and Warn functions like seelog

Example

go get gopkg.in/vrecan/death.v3

Use The Library

package main

import (
	DEATH "github.com/vrecan/death/v3"
	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

package main

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

func main() {
	death := DEATH.NewDeath(SYS.SIGINT, SYS.SIGTERM) //pass the signals you want to end your application
	objects := make([]io.Closer, 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
	err := death.WaitForDeath(objects...) // this will finish when a signal of your type is sent to your application
	if err != nil {
		log.Println(err)
		os.Exit(1)
	}
}

type NewType struct {
}

func (c *NewType) Close() error {
	return nil
}

Or close using an anonymous function

package main

import (
	DEATH "github.com/vrecan/death/v3"
	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.WaitForDeathWithFunc(func(){
		//do whatever you want on death
	})
}

Release Process

Rules for release branches:

  • If you are releasing a new major version you need to branch off of master into a branch release-branch.v# (example release-branch.v2 for a 2.x release)
  • If you are releasing a minor or patch update to an existing major release make sure to merge master into the release branch

Rules for tagging and publishing the release

When you are ready to publish the release make sure you...

  1. Merge your changes into the correct release branch.
  2. Check out the release branch locally (example: git pull origin release-branch.v3)
  3. Create a new tag for the specific release version you will publish (example: git tag v3.0.1)
  4. Push the tag up to github (example: git push origin v3.0.1)
  5. Go to the release tab in github
  6. Select the target branch as the release branch and type in the tag name (tagname should include v so example: v3.0.1)
  7. Write a title and a well worded description on exactly what is in this change
  8. Click publish release

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory