Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

feat: Durability test RTC connections #329

Merged
merged 19 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ ci/integration/bin
ci/integration/env.sh
coder-sdk/env.sh
.vscode
vendor
2 changes: 0 additions & 2 deletions agent/doc.go

This file was deleted.

106 changes: 0 additions & 106 deletions agent/server.go

This file was deleted.

194 changes: 0 additions & 194 deletions agent/stream.go

This file was deleted.

6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ require (
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f
github.com/klauspost/compress v1.10.8 // indirect
github.com/manifoldco/promptui v0.8.0
github.com/pion/datachannel v1.4.21
github.com/pion/dtls/v2 v2.0.9
github.com/pion/ice/v2 v2.1.5
github.com/pion/turn/v2 v2.0.5
github.com/pion/webrtc/v3 v3.0.24
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
github.com/rjeczalik/notify v0.9.2
github.com/spf13/cobra v1.1.3
go.coder.com/retry v1.2.0
golang.org/x/net v0.0.0-20210420210106-798c2154c571
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
go.coder.com/cli v0.4.0/go.mod h1:hRTOURCR3LJF1FRW9arecgrzX+AHG7mfYMwThPIgq+w=
go.coder.com/flog v0.0.0-20190906214207-47dd47ea0512 h1:DjCS6dRQh+1PlfiBmnabxfdrzenb0tAwJqFxDEH/s9g=
go.coder.com/flog v0.0.0-20190906214207-47dd47ea0512/go.mod h1:83JsYgXYv0EOaXjIMnaZ1Fl6ddNB3fJnDZ/8845mUJ8=
go.coder.com/retry v1.2.0 h1:ODdUPu9cb9pcbeAM5j2YqJHUgfFbN60vmhtlWIKZGLo=
go.coder.com/retry v1.2.0/go.mod h1:ihkJszQk8F+yaFL2pcIku9MzbYo+U8vka4IsvQSXVfE=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
Expand Down
27 changes: 13 additions & 14 deletions internal/cmd/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package cmd

import (
"context"
"log"
"net/url"
"os"
"os/signal"
"syscall"

"cdr.dev/slog"
"cdr.dev/slog/sloggers/sloghuman"
"github.com/spf13/cobra"
"golang.org/x/xerrors"

"cdr.dev/coder-cli/agent"
"cdr.dev/coder-cli/wsnet"
)

func agentCmd() *cobra.Command {
Expand Down Expand Up @@ -46,8 +47,6 @@ coder agent start --coder-url https://my-coder.com --token xxxx-xxxx
`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
log := slog.Make(sloghuman.Sink(cmd.OutOrStdout()))

if coderURL == "" {
var ok bool
coderURL, ok = os.LookupEnv("CODER_URL")
Expand All @@ -74,18 +73,18 @@ coder agent start --coder-url https://my-coder.com --token xxxx-xxxx
}
}

server, err := agent.NewServer(agent.ServerArgs{
Log: log,
CoderURL: u,
Token: token,
})
listener, err := wsnet.Listen(context.Background(), wsnet.ListenEndpoint(u, token))
if err != nil {
return xerrors.Errorf("creating agent server: %w", err)
return xerrors.Errorf("listen: %w", err)
}

err = server.Run(ctx)
if err != nil && !xerrors.Is(err, context.Canceled) && !xerrors.Is(err, context.DeadlineExceeded) {
return xerrors.Errorf("running agent server: %w", err)
// Block until user sends SIGINT or SIGTERM
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
<-sigs

if err = listener.Close(); err != nil {
log.Panic(err)
}

return nil
Expand Down
Loading