ScuttleBot

fix: delay initial bot sync so bridge creates channels first

lmata 2026-04-04 00:17 trunk
Commit e6c41b360806db35e47b2cf61a4c7aa4f518cd2a06cbed428999e45f880e8fd4
1 file changed +6 -3
--- cmd/scuttlebot/main.go
+++ cmd/scuttlebot/main.go
@@ -278,12 +278,15 @@
278278
reg.SetOnlineTimeout(time.Duration(p.AgentPolicy.OnlineTimeoutSecs) * time.Second)
279279
}
280280
botMgr.Sync(ctx, specs)
281281
})
282282
283
- // Initial bot sync from loaded policies.
284
- {
283
+ // Initial bot sync — delayed to let the bridge create channels first.
284
+ // Bots with join_all_channels need channels to exist before they query
285
+ // the channel list. The bridge takes ~2s to connect and join.
286
+ go func() {
287
+ time.Sleep(5 * time.Second)
285288
p := policyStore.Get()
286289
specs := make([]botmanager.BotSpec, len(p.Behaviors))
287290
for i, b := range p.Behaviors {
288291
specs[i] = botmanager.BotSpec{
289292
ID: b.ID,
@@ -293,11 +296,11 @@
293296
RequiredChannels: b.RequiredChannels,
294297
Config: b.Config,
295298
}
296299
}
297300
botMgr.Sync(ctx, specs)
298
- }
301
+ }()
299302
300303
// Agent reaper — periodically removes stale agents based on policy.
301304
go func() {
302305
ticker := time.NewTicker(1 * time.Hour)
303306
defer ticker.Stop()
304307
--- cmd/scuttlebot/main.go
+++ cmd/scuttlebot/main.go
@@ -278,12 +278,15 @@
278 reg.SetOnlineTimeout(time.Duration(p.AgentPolicy.OnlineTimeoutSecs) * time.Second)
279 }
280 botMgr.Sync(ctx, specs)
281 })
282
283 // Initial bot sync from loaded policies.
284 {
 
 
 
285 p := policyStore.Get()
286 specs := make([]botmanager.BotSpec, len(p.Behaviors))
287 for i, b := range p.Behaviors {
288 specs[i] = botmanager.BotSpec{
289 ID: b.ID,
@@ -293,11 +296,11 @@
293 RequiredChannels: b.RequiredChannels,
294 Config: b.Config,
295 }
296 }
297 botMgr.Sync(ctx, specs)
298 }
299
300 // Agent reaper — periodically removes stale agents based on policy.
301 go func() {
302 ticker := time.NewTicker(1 * time.Hour)
303 defer ticker.Stop()
304
--- cmd/scuttlebot/main.go
+++ cmd/scuttlebot/main.go
@@ -278,12 +278,15 @@
278 reg.SetOnlineTimeout(time.Duration(p.AgentPolicy.OnlineTimeoutSecs) * time.Second)
279 }
280 botMgr.Sync(ctx, specs)
281 })
282
283 // Initial bot sync — delayed to let the bridge create channels first.
284 // Bots with join_all_channels need channels to exist before they query
285 // the channel list. The bridge takes ~2s to connect and join.
286 go func() {
287 time.Sleep(5 * time.Second)
288 p := policyStore.Get()
289 specs := make([]botmanager.BotSpec, len(p.Behaviors))
290 for i, b := range p.Behaviors {
291 specs[i] = botmanager.BotSpec{
292 ID: b.ID,
@@ -293,11 +296,11 @@
296 RequiredChannels: b.RequiredChannels,
297 Config: b.Config,
298 }
299 }
300 botMgr.Sync(ctx, specs)
301 }()
302
303 // Agent reaper — periodically removes stale agents based on policy.
304 go func() {
305 ticker := time.NewTicker(1 * time.Hour)
306 defer ticker.Stop()
307

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button