Wire process identity cancellation and shared HTTP server lifecycle
This commit is contained in:
@@ -1,11 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"gitea.maximumdirect.net/eric/scriptorium/internal/adapter/cli"
|
||||
"go.maximumdirect.net/commandkit"
|
||||
)
|
||||
|
||||
var version = "dev"
|
||||
var revision = ""
|
||||
|
||||
func main() {
|
||||
os.Exit(cli.Run(os.Args[1:], os.Stdout, os.Stderr))
|
||||
os.Exit(runWithSignals(os.Args[1:], os.Stdout, os.Stderr))
|
||||
}
|
||||
|
||||
func runWithSignals(args []string, stdout, stderr io.Writer) int {
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
return run(ctx, args, stdout, stderr)
|
||||
}
|
||||
|
||||
func run(ctx context.Context, args []string, stdout, stderr io.Writer) int {
|
||||
return cli.Execute(ctx, commandkit.Identity{Name: "scriptorium", Version: version, Revision: revision}, args, stdout, stderr).Status
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user