Skip to content

110y/run

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

run

run is a tiny module which makes spinning up and tearing down for a server program written in Go be more easier. See an example below for how to use.

import (
	"context"

	"github.com/110y/run"
)

func main() {
	run.Run(func(ctx context.Context) int {
		// Spin up your server here.

		// This blocks until one of termination signals (unix.SIGHUP, unix.SIGINT, unix.SIGTERM or unix.SIGQUIT) will be passed.
		<-ctx.Done()

		// Tear down your server here.

		// After this function has finished, run.Run exits the process with returned value of this function as its exit code.
		return 0
	})
}

See https://pkg.go.dev/github.com/110y/run for more details.