Skip to content

Instantly share code, notes, and snippets.

@dio
Created November 28, 2021 23:11
Show Gist options
  • Save dio/d4d89fd0d31f82322406ef6c6ce7c457 to your computer and use it in GitHub Desktop.
Save dio/d4d89fd0d31f82322406ef6c6ce7c457 to your computer and use it in GitHub Desktop.
package envoy
import (
"context"
"io"
"os/exec"
)
type Options struct{}
type Runtime struct {
ctx context.Context
cancel context.CancelFunc
Out, Err io.Writer
}
func NewRuntime(opts Options) *Runtime {
ctx, cancel := context.WithCancel(context.Background())
return &Runtime{
ctx: ctx,
cancel: cancel,
}
}
func (r *Runtime) Name() string {
return "envoy"
}
// Serve starts the server.
func (r *Runtime) Serve() error {
return exec.CommandContext(r.ctx, "/home/dio/.func-e/versions/1.20.0/bin/envoy", "-c", "/home/dio/tetrate/bff/bff/internal/envoy/config.yaml").Run()
}
// GracefulStop stops the server gracefully.
func (r *Runtime) GracefulStop() {
r.cancel()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment