Documentation
¶
Overview ¶
Package runner provides means for starting and stopping servers and background jobs.
Example ¶
package main
import (
"log"
"github.com/jasonhancock/runner"
)
type myServer struct{}
func (s *myServer) Run() error {
log.Println("starting...")
return nil
}
func (s *myServer) Stop() error {
log.Println("stopping...")
return nil
}
func main() {
// create a context that will be cancelled when an os signal tells the process to shut down.
ctx := runner.Context()
// Fire up some background job that will shutdown when ctx is cancelled.
go func() {
// some background job....
<-ctx.Done()
}()
// start up a server. This call will block.
runner.RunServer(&myServer{})
}
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
Signals defines the list of signals that will cause the server to shutdown
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.