Main implements the main function of the caddy command. Call this if Caddy is to be the main() of your program.
()
| 64 | // Main implements the main function of the caddy command. |
| 65 | // Call this if Caddy is to be the main() of your program. |
| 66 | func Main() { |
| 67 | if len(os.Args) == 0 { |
| 68 | fmt.Printf("[FATAL] no arguments provided by OS; args[0] must be command\n") |
| 69 | os.Exit(caddy.ExitCodeFailedStartup) |
| 70 | } |
| 71 | |
| 72 | if err := defaultFactory.Build().Execute(); err != nil { |
| 73 | var exitError *exitError |
| 74 | if errors.As(err, &exitError) { |
| 75 | os.Exit(exitError.ExitCode) |
| 76 | } |
| 77 | os.Exit(1) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | // handlePingbackConn reads from conn and ensures it matches |
| 82 | // the bytes in expect, or returns an error if it doesn't. |