Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

synapse ws reconnect #42

Merged
merged 6 commits into from
Mar 21, 2022
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
20 changes: 19 additions & 1 deletion cmd/synapse/bin.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ func run(cmd *cobra.Command, args []string) {
logger.Fatalf("Could not instantiate proxyhandler %v", err)
}

// All attempts to connect to lambdatest server failed
connectionFailed := make(chan struct{})

wg.Add(1)
go synapse.InitiateConnection(ctx, &wg)
go synapse.InitiateConnection(ctx, &wg, connectionFailed)

wg.Add(1)
go func() {
Expand Down Expand Up @@ -138,6 +141,21 @@ func run(cmd *cobra.Command, args []string) {
case <-time.After(global.GracefulTimeout):
logger.Errorf("Graceful timeout exceeded. Brutally killing the application")
}
}

case <-connectionFailed:
VikrantKS marked this conversation as resolved.
Show resolved Hide resolved
{
logger.Debugf("main: all attempts to connect to lamdatest server failed ....")
// tell the goroutines to stop
logger.Debugf("main: telling goroutines to stop")
cancel()
select {
case <-done:
logger.Debugf("Go routines exited within timeout")
case <-time.After(global.GracefulTimeout):
logger.Errorf("Graceful timeout exceeded. Brutally killing the application")
}
os.Exit(0)

}
case <-done:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
synapse:
image: lambdatest/synapse:latest
stop_signal: SIGINT
restart: always
restart: on-failure
networks:
- test-at-scale
hostname: synapse
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ require (
github.com/klauspost/compress v1.11.13 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lestrrat-go/backoff v1.0.1 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
github.com/lestrrat-go/backoff v1.0.1 h1:Gphaach0QvvtaHmR9U8hwXNHXWckPyD8V6S+V+D184c=
github.com/lestrrat-go/backoff v1.0.1/go.mod h1:5QVJKC49Q5yQvCrpup0ZqzDGHEO/O4H82cnDuYdumkw=
github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/synapse.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import (
// SynapseManager denfines operations for synapse client
type SynapseManager interface {
// InitiateConnection initiates the connection with LT cloud
InitiateConnection(ctx context.Context, wg *sync.WaitGroup)
InitiateConnection(ctx context.Context, wg *sync.WaitGroup, connectionFailed chan struct{})
}
29 changes: 15 additions & 14 deletions pkg/global/synapseconstants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ import (

// all constant related to synapse
const (
GracefulTimeout = 100000 * time.Millisecond
ProxyServerPort = "8000"
DirectoryPermissions = 0755
FilePermissions = 0755
GitConfigFileName = "oauth"
RepoSecretsFileName = "reposecrets"
SynapseContainerURL = "http://synapse:8000"
NetworkEnvName = "NetworkName"
AutoRemoveEnv = "AutoRemove"
SynapseHostEnv = "synapsehost"
LocalEnv = "local"
NetworkName = "test-at-scale"
AutoRemove = true
Local = true
GracefulTimeout = 100 * time.Second
ProxyServerPort = "8000"
DirectoryPermissions = 0755
FilePermissions = 0755
GitConfigFileName = "oauth"
RepoSecretsFileName = "reposecrets"
SynapseContainerURL = "http://synapse:8000"
NetworkEnvName = "NetworkName"
AutoRemoveEnv = "AutoRemove"
SynapseHostEnv = "synapsehost"
LocalEnv = "local"
NetworkName = "test-at-scale"
AutoRemove = true
Local = true
MaxConnectionAttempts = 10
)

// SocketURL lambdatest url for synapse socket
Expand Down
Loading