Skip to content

Commit a9767b6

Browse files
authored
fix(cloud): only start WS Client if config.CloudToken is set (#27)
1 parent 8ffe66a commit a9767b6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

cloud.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ func handleCloudRegister(c *gin.Context) {
6868
return
6969
}
7070

71+
if config.CloudToken == "" {
72+
logger.Info("Starting websocket client due to adoption")
73+
go RunWebsocketClient()
74+
}
75+
7176
config.CloudToken = tokenResp.SecretToken
7277
config.CloudURL = req.CloudAPI
7378

main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ func Main() {
6666
}()
6767
//go RunFuseServer()
6868
go RunWebServer()
69-
go RunWebsocketClient()
69+
// If the cloud token isn't set, the client won't be started by default.
70+
// However, if the user adopts the device via the web interface, handleCloudRegister will start the client.
71+
if config.CloudToken != "" {
72+
go RunWebsocketClient()
73+
}
7074
sigs := make(chan os.Signal, 1)
7175
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
7276
<-sigs

0 commit comments

Comments
 (0)