mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-19 15:53:17 +00:00
Standardize exit codes and improve shutdown handling; update gitignore
This commit is contained in:
parent
2141626269
commit
b780f0f49b
7 changed files with 243 additions and 38 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue