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: about 3 hours ago
JSON representation
go application lifecycle manager
- Host: GitHub
- URL: https://github.com/daangn/lifecycle
- Owner: daangn
- Created: 2021-12-30T06:42:22.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-17T14:56:52.000Z (over 2 years ago)
- Last Synced: 2024-08-04T04:01:33.714Z (3 months ago)
- Topics: go, golang, graceful-shutdown
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 4
- Watchers: 21
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lifecycle
Golang application lifecycle manager.
**Note: This is not an official Daangn project**
# Usage
```go
package mainimport (
"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)
}
}
```