"//grpc",
"//mtls",
"//proto/service/attest",
+ "//utils/context",
],
)
package main
import (
- "context"
"flag"
"fmt"
- "os/signal"
- "syscall"
"go.fuhry.dev/runtime/attestation/internal/attestation"
"go.fuhry.dev/runtime/grpc"
"go.fuhry.dev/runtime/mtls"
attest_pb "go.fuhry.dev/runtime/proto/service/attest"
+ "go.fuhry.dev/runtime/utils/context"
)
func main() {
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
flag.Parse()
"//grpc",
"//mtls",
"//proto/service/attest",
+ "//utils/context",
"@org_golang_google_grpc//:grpc",
],
)
package main
import (
- "context"
"flag"
- "os/signal"
- "syscall"
"go.fuhry.dev/runtime/attestation/internal/attestation"
"go.fuhry.dev/runtime/grpc"
"go.fuhry.dev/runtime/mtls"
attest_pb "go.fuhry.dev/runtime/proto/service/attest"
+ "go.fuhry.dev/runtime/utils/context"
google_grpc "google.golang.org/grpc"
)
panic(err)
}
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
err = s.PublishAndServe(ctx, func(s *google_grpc.Server) {
attest_pb.RegisterAttestServer(s, attestation.NewAttestationServer())
"//grpc",
"//mtls",
"//proto/service/bryston_ctl",
+ "//utils/context",
"//utils/log",
],
)
package main
import (
- "context"
"flag"
- "os/signal"
- "syscall"
"go.fuhry.dev/runtime/automation/bryston_ctl"
"go.fuhry.dev/runtime/grpc"
"go.fuhry.dev/runtime/mtls"
bryston_ctl_pb "go.fuhry.dev/runtime/proto/service/bryston_ctl"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/log"
)
func main() {
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
model, modelFF := bryston_ctl.NewBrystonModelFlag()
flag.Func("model", "Bryston device model to control", modelFF)
"//grpc",
"//mtls",
"//proto/service/bryston_ctl",
+ "//utils/context",
"//utils/log",
"@org_golang_google_grpc//:grpc",
],
package main
import (
- "context"
"flag"
- "os/signal"
- "syscall"
google_grpc "google.golang.org/grpc"
"go.fuhry.dev/runtime/grpc"
"go.fuhry.dev/runtime/mtls"
bryston_ctl_pb "go.fuhry.dev/runtime/proto/service/bryston_ctl"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/log"
)
log.Panic(err)
}
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
ctl, err := bryston_ctl.NewController()
if err != nil {
visibility = ["//visibility:private"],
deps = [
"//metrics/metricbus/mbclient",
+ "//utils/context",
"//utils/log",
"@com_github_coreos_go_systemd//daemon",
"@com_github_mdlayher_apcupsd//:apcupsd",
package main
import (
- "context"
"flag"
- "os/signal"
"sync"
- "syscall"
"time"
"github.com/coreos/go-systemd/daemon"
"github.com/mdlayher/apcupsd"
"go.fuhry.dev/runtime/metrics/metricbus/mbclient"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/log"
)
flag.StringVar(&apcUpsdAddr, "apcupsd-addr", apcUpsdAddr, "address at which apcupsd can be contacted")
flag.IntVar(&nominalPower, "apcupsd-nominal-power", nominalPower, "max power output in W for the UPS - only used if apcupsd does not specify NOMPOWER")
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
flag.Parse()
svc := mbclient.NewService(ctx)
"//grpc",
"//mtls",
"//proto/service/echo",
+ "//utils/context",
"//utils/log",
],
)
package main
import (
- "context"
"flag"
- "os/signal"
- "syscall"
"go.fuhry.dev/runtime/grpc"
"go.fuhry.dev/runtime/mtls"
echo_pb "go.fuhry.dev/runtime/proto/service/echo"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/log"
)
func main() {
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
flag.Parse()
logger := log.Default().WithPrefix("EchoClient")
"//grpc",
"//mtls",
"//proto/service/echo",
+ "//utils/context",
"@org_golang_google_grpc//:grpc",
],
)
package main
import (
- "context"
"flag"
- "os/signal"
- "syscall"
"go.fuhry.dev/runtime/echo"
"go.fuhry.dev/runtime/grpc"
"go.fuhry.dev/runtime/mtls"
echo_pb "go.fuhry.dev/runtime/proto/service/echo"
+ "go.fuhry.dev/runtime/utils/context"
google_grpc "google.golang.org/grpc"
)
panic(err)
}
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
err = s.PublishAndServe(ctx, func(s *google_grpc.Server) {
echo_pb.RegisterEchoServer(s, echo.NewEchoServer())
deps = [
"//constants",
"//ephs",
+ "//utils/context",
"//utils/log",
"@com_github_urfave_cli_v3//:cli",
],
package main
import (
- "context"
"errors"
"flag"
"fmt"
"io"
"os"
- "os/signal"
"path"
"strings"
- "syscall"
"github.com/urfave/cli/v3"
"go.fuhry.dev/runtime/constants"
"go.fuhry.dev/runtime/ephs"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/log"
)
}
func main() {
- ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
defer cancel()
flag.Parse()
"//grpc",
"//mtls",
"//proto/service/ephs",
+ "//utils/context",
"//utils/log",
"@org_golang_google_grpc//:grpc",
],
package main
import (
- "context"
"flag"
- "os/signal"
- "syscall"
"go.fuhry.dev/runtime/ephs/servicer"
"go.fuhry.dev/runtime/grpc"
"go.fuhry.dev/runtime/mtls"
ephs_pb "go.fuhry.dev/runtime/proto/service/ephs"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/log"
google_grpc "google.golang.org/grpc"
log.Fatal(err)
}
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
err = s.PublishAndServe(ctx, func(s *google_grpc.Server) {
ephs_pb.RegisterEphsServer(s, serv)
deps = [
"//grpc",
"//mtls",
+ "//utils/context",
"//utils/log",
"@org_golang_google_grpc//health/grpc_health_v1",
],
package main
import (
- "context"
"flag"
"net"
"os"
- "os/signal"
"strconv"
- "syscall"
"time"
"go.fuhry.dev/runtime/grpc"
"go.fuhry.dev/runtime/mtls"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/log"
"google.golang.org/grpc/health/grpc_health_v1"
}
}
- ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
defer cancel()
var deadline time.Time
"//config_watcher",
"//ephs",
"//http",
+ "//utils/context",
"//utils/log",
"@com_github_coreos_go_systemd//daemon",
"@in_gopkg_yaml_v3//:yaml_v3",
package main
import (
- "context"
"flag"
- "os/signal"
- "syscall"
"time"
"github.com/coreos/go-systemd/daemon"
"go.fuhry.dev/runtime/config_watcher"
"go.fuhry.dev/runtime/ephs"
"go.fuhry.dev/runtime/http"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/log"
)
func main() {
- ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
defer cancel()
ephs.DefaultClientContext = ctx
visibility = ["//visibility:private"],
deps = [
"//machines",
+ "//utils/context",
"//utils/log",
],
)
package main
import (
- "context"
"flag"
"os"
- "os/signal"
- "syscall"
"go.fuhry.dev/runtime/machines"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/log"
)
flag.Parse()
logger := log.WithPrefix("main")
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
client, err := machines.NewDefaultMachinesClient("host.attestation.client")
if err != nil {
visibility = ["//visibility:private"],
deps = [
"//metrics/metricbus/mbserver",
+ "//utils/context",
"//utils/log",
],
)
package main
import (
- "context"
"flag"
- "os/signal"
- "syscall"
"go.fuhry.dev/runtime/metrics/metricbus/mbserver"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/log"
)
func main() {
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
serverCtx, cancel := context.WithCancel(context.Background())
flag.Parse()
visibility = ["//visibility:private"],
deps = [
"//metrics/mtls",
+ "//utils/context",
"@com_github_coreos_go_systemd//daemon",
],
)
package main
import (
- "context"
"flag"
- "os/signal"
- "syscall"
"time"
"github.com/coreos/go-systemd/daemon"
"go.fuhry.dev/runtime/metrics/mtls"
+ "go.fuhry.dev/runtime/utils/context"
)
func main() {
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
flag.Parse()
svc := mtls.NewMtlsMetricsService(ctx)
visibility = ["//visibility:private"],
deps = [
"//mtls/fsnotify",
+ "//utils/context",
"//utils/debounce",
"//utils/hashset",
"//utils/log",
import (
"bytes"
- "context"
"crypto"
"fmt"
"io"
"time"
"go.fuhry.dev/runtime/mtls/fsnotify"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/debounce"
"go.fuhry.dev/runtime/utils/hashset"
"go.fuhry.dev/runtime/utils/log"
log.SetLevel(log.DEBUG)
}
- ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
logger := log.Default().WithPrefix("supervisor")
defer cancel()
"//constants",
"//mtls",
"//sd",
+ "//utils/context",
"//utils/log",
"@com_github_coreos_go_systemd//daemon",
],
package main
import (
- "context"
"encoding/json"
"flag"
"fmt"
"net/http"
- "os/signal"
"sync"
- "syscall"
"time"
"github.com/coreos/go-systemd/daemon"
"go.fuhry.dev/runtime/constants"
"go.fuhry.dev/runtime/mtls"
"go.fuhry.dev/runtime/sd"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/log"
)
func main() {
mtls.SetDefaultIdentity("node-exporter")
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
serverCtx, cancel := context.WithCancel(context.Background())
defer cancel()
"//rand",
"//sase",
"//sd",
+ "//utils/context",
],
)
package main
import (
- "context"
"flag"
"fmt"
- "os/signal"
"strconv"
"strings"
- "syscall"
"time"
"go.fuhry.dev/runtime/constants"
"go.fuhry.dev/runtime/rand"
"go.fuhry.dev/runtime/sase"
"go.fuhry.dev/runtime/sd"
+ "go.fuhry.dev/runtime/utils/context"
)
func main() {
flag.Parse()
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
listenPort, err := strconv.Atoi(addr[strings.LastIndex(addr, ":")+1:])
if err != nil {
deps = [
"//mtls",
"//sd",
+ "//utils/context",
"@io_etcd_go_etcd_client_v3//:client",
],
)
package main
import (
- "context"
"crypto/tls"
"encoding/json"
"flag"
"fmt"
"net"
"net/http"
- "os/signal"
"strings"
"sync"
- "syscall"
etcd_client "go.etcd.io/etcd/client/v3"
"go.fuhry.dev/runtime/mtls"
"go.fuhry.dev/runtime/sd"
+ "go.fuhry.dev/runtime/utils/context"
)
func main() {
keys := make(map[string][]byte, 0)
keysLock := &sync.RWMutex{}
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
handler := http.NewServeMux()
server := &http.Server{
deps = [
"//constants",
"//sd",
+ "//utils/context",
"//utils/hostname",
],
)
package main
import (
- "context"
"flag"
- "os/signal"
"strings"
- "syscall"
"go.fuhry.dev/runtime/constants"
"go.fuhry.dev/runtime/sd"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/hostname"
)
func main() {
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
svc := &sd.SDPublisher{}
var port uint
deps = [
"//constants",
"//sd",
+ "//utils/context",
"//utils/hostname",
"//utils/log",
],
package main
import (
- "context"
"flag"
"fmt"
"os"
- "os/signal"
"path"
"strings"
"sync"
- "syscall"
"go.fuhry.dev/runtime/constants"
"go.fuhry.dev/runtime/sd"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/hostname"
"go.fuhry.dev/runtime/utils/log"
)
flag.StringVar(®ion, "region", defaultRegion, "regional shard to publish under; separate multiple shards with commas")
flag.Parse()
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
if len(confs) < 1 {
flag.Usage()
deps = [
"//constants",
"//sd",
+ "//utils/context",
],
)
package main
import (
- "context"
"flag"
"fmt"
"os"
- "os/signal"
- "syscall"
"time"
"go.fuhry.dev/runtime/constants"
"go.fuhry.dev/runtime/sd"
+ "go.fuhry.dev/runtime/utils/context"
)
func main() {
panic(err)
}
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
watcher := &sd.SDWatcher{
Domain: domain,
srcs = ["main.go"],
importpath = "go.fuhry.dev/runtime/metrics/metricbus/mbclient/example",
visibility = ["//visibility:private"],
- deps = ["//metrics/metricbus/mbclient"],
+ deps = [
+ "//metrics/metricbus/mbclient",
+ "//utils/context",
+ ],
)
go_binary(
package main
import (
- "context"
"flag"
"math/rand"
- "os/signal"
- "syscall"
"time"
"go.fuhry.dev/runtime/metrics/metricbus/mbclient"
+ "go.fuhry.dev/runtime/utils/context"
)
func main() {
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
flag.Parse()
svc := mbclient.NewServiceWithDiscriminator(ctx, "merr")
"//mtls/certutil",
"//net/dns",
"//utils",
+ "//utils/context",
"//utils/hostname",
"//utils/log",
"@com_github_go_ldap_ldap_v3//:ldap",
package sd
import (
- "context"
+ "errors"
"flag"
"fmt"
"sync"
"go.etcd.io/etcd/client/pkg/v3/srv"
etcd_client "go.etcd.io/etcd/client/v3"
"go.fuhry.dev/runtime/mtls"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/hostname"
"go.fuhry.dev/runtime/utils/log"
)
}
clientSingleton, err = NewEtcdClient(id, etcdDiscoveryDomain)
+ if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
+ return nil, err
+ }
if err == nil {
break
}
func NewEtcdClientWithDeadline(id mtls.Identity, domain string, deadline time.Time) (*etcd_client.Client, error) {
var client *etcd_client.Client
- tlsConfig, err := id.TlsConfig(context.Background())
+ ctx, _ := context.Interruptible()
+
+ tlsConfig, err := id.TlsConfig(ctx)
if err != nil {
return nil, fmt.Errorf("failed to setup client TLS configuration: %v", err)
}
dialTimeout := time.Until(deadline)
clientConfig := etcd_client.Config{
+ Context: ctx,
DialTimeout: dialTimeout,
Endpoints: clients.Endpoints,
TLS: tlsConfig,
"//metrics/metricbus/mbclient",
"//mtls",
"//sd",
+ "//utils/context",
"//utils/log",
"@com_github_distribution_distribution_v3//configuration",
"@com_github_distribution_distribution_v3//registry/auth/htpasswd",
package main
import (
- "context"
"crypto/tls"
"flag"
"fmt"
"net/http"
_ "net/http/pprof"
"os"
- "os/signal"
"strconv"
- "syscall"
"github.com/distribution/distribution/v3/configuration"
_ "github.com/distribution/distribution/v3/registry/auth/htpasswd"
"go.fuhry.dev/runtime/metrics/metricbus/mbclient"
"go.fuhry.dev/runtime/mtls"
"go.fuhry.dev/runtime/sd"
+ "go.fuhry.dev/runtime/utils/context"
"go.fuhry.dev/runtime/utils/log"
)
flag.StringVar(&configPath, "registry.config-path", "config.yml", "path to configuration file")
flag.Parse()
logger = log.WithPrefix("registry")
- ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
+ ctx, cancel := context.Interruptible()
+ defer cancel()
metricsService := mbclient.NewService(ctx)
defer metricsService.FlushAndWait()