Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nasa9084/syg

very simple signal-callback mapper
https://github.com/nasa9084/syg

go golang signal signal-processing

Last synced: 11 days ago
JSON representation

very simple signal-callback mapper

Awesome Lists containing this project

README

        

# syg
[![Build Status](https://travis-ci.org/nasa9084/syg.svg?branch=master)](https://travis-ci.org/nasa9084/syg)
[![GoDoc](https://godoc.org/github.com/nasa9084/syg?status.svg)](https://godoc.org/github.com/nasa9084/syg)
-----

a very simple signal handler for golang

## SYNOPSIS

``` go
func ExampleSyg() {
s := &http.Server{}
waitCh := make(chan struct{})

syg.Listen(func(os.Signal) {
s.Shutdown(context.Background())
close(waitCh)
}, os.Interrupt)

if err := s.ListenAndServe(); err != http.ErrServerClosed {
// some error handling
}
<-waitCh
}
```