Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 594 Bytes

README.md

File metadata and controls

43 lines (33 loc) · 594 Bytes

Lifecycle

Golang application lifecycle manager.

Note: This is not an official Daangn project

Usage

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)
	}
}