From b780f0f49b191a6724b7ec54aa62a97d23977231 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Fri, 12 Jul 2019 10:07:11 -0600 Subject: Standardize exit codes and improve shutdown handling; update gitignore --- cmd/main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'cmd/main.go') diff --git a/cmd/main.go b/cmd/main.go index 4691b37..16d065b 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -23,10 +23,15 @@ import ( "log" "net" "os" + + "github.com/caddyserver/caddy/v2" ) -// Main executes the main function of the caddy command. +// Main implements the main function of the caddy command. +// Call this if Caddy is to be the main() if your program. func Main() { + caddy.TrapSignals() + if len(os.Args) <= 1 { fmt.Println(usageString()) return @@ -35,7 +40,7 @@ func Main() { subcommand, ok := commands[os.Args[1]] if !ok { fmt.Printf("%q is not a valid command\n", os.Args[1]) - os.Exit(2) + os.Exit(caddy.ExitCodeFailedStartup) } if exitCode, err := subcommand(); err != nil { -- cgit v1.2.3