Ecosyste.ms: Awesome

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

https://github.com/daangn/lifecycle

go application lifecycle manager
https://github.com/daangn/lifecycle

go golang graceful-shutdown

Last synced: 27 days ago
JSON representation

go application lifecycle manager

Lists

README

        

# Lifecycle

Golang application lifecycle manager.

**Note: This is not an official Daangn project**

# Usage

```go
package main

import (
"net"
"net/http"

"github.com/daangn/lifecycle"
"google.golang.org/grpc"
)

type yourWorkerApp interface{
Start() error
GracefulStop()
}

func main() {
var (
worker yourWorkerApp
httpServer *http.Server
grpcServer *grpc.Server
grpcLis net.Listener
)

// ...

if err := lifecycle.Run(
lifecycle.WithGRPC(grpcServer, grpcLis),
lifecycle.WithHTTP(httpServer),
lifecycle.WithApp(worker),
); err != nil {
panic(err)
}
}
```