Skip to content

Commit 01ec45c

Browse files
committed
Add ENVOY_KILL_API env variable
This supports istio by allowing for a separate URL for the quitquitquit command. Fixes #6
1 parent 866798b commit 01ec45c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ When the application exits, as long as it does so with exit code 0, `envoy-prefl
2020
| Variable | Purpose |
2121
|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
2222
| `ENVOY_ADMIN_API` | This is the path to envoy's administration interface, in the format `http://127.0.0.1:9010`. If provided, `envoy-preflight` will poll this url at `/server_info` waiting for envoy to report as `LIVE`. If provided and local (`127.0.0.1` or `localhost`), then envoy will be instructed to shut down if the application exits cleanly. |
23+
| `ENVOY_KILL_API` | This is the endpoint of the POST command to kill envoy, which defaults to `$ENVOY_ADMIN_API/quitquitquit`, but you can provide any value in format `http://127.0.0.1:9010/quitquitquit`. This can be used to support istio by providing the pilot-agent port. |
2324
| `NEVER_KILL_ENVOY` | If provided and set to `true`, `envoy-preflight` will not instruct envoy to exit under any circumstances. |
2425
| `ALWAYS_KILL_ENVOY` | If provided and set to `true`, `envoy-preflight` will instruct envoy to exit, even if the main application exits with a nonzero exit code. |
2526
| `START_WITHOUT_ENVOY` | If provided and set to `true`, `envoy-preflight` will not wait for envoy to be LIVE before starting the main application. However, it will still instruct envoy to exit. |

main.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ func main() {
2424
block(host)
2525
}
2626

27+
killAPI, killOk := os.LookupEnv("ENVOY_KILL_API")
28+
if !killOk {
29+
killAPI = fmt.Sprintf("%s/quitquitquit", host)
30+
}
31+
2732
if len(os.Args) < 2 {
2833
return
2934
}
@@ -72,9 +77,7 @@ func main() {
7277
// We're configured never to kill envoy, do nothing
7378
case os.Getenv("ALWAYS_KILL_ENVOY") == "true", exitCode == 0:
7479
// Either we had a clean exit, or we are configured to kill envoy anyway
75-
url := fmt.Sprintf("%s/quitquitquit", host)
76-
77-
_ = typhon.NewRequest(context.Background(), "POST", url, nil).Send().Response()
80+
_ = typhon.NewRequest(context.Background(), "POST", killAPI, nil).Send().Response()
7881
}
7982

8083
os.Exit(exitCode)

0 commit comments

Comments
 (0)