summaryrefslogtreecommitdiff
path: root/cmd/main.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-07-12 10:07:11 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-07-12 10:07:11 -0600
commitb780f0f49b191a6724b7ec54aa62a97d23977231 (patch)
tree984a9f1f816fd9a092f0bba63a38c3099c43b7b1 /cmd/main.go
parent2141626269201d902b736711a808098e6d175cbb (diff)
Standardize exit codes and improve shutdown handling; update gitignore
Diffstat (limited to 'cmd/main.go')
-rw-r--r--cmd/main.go9
1 files changed, 7 insertions, 2 deletions
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 {