From 7f39da8718b792d136ce38ffebd00c2478fa527f Mon Sep 17 00:00:00 2001 From: Julian Sommer <115516918+juliansommer@users.noreply.github.com> Date: Mon, 2 Feb 2026 08:14:40 +1000 Subject: [PATCH] fix: state on launch --- hive/daemon/daemon.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/hive/daemon/daemon.go b/hive/daemon/daemon.go index cce7a5a48..8bf297de0 100644 --- a/hive/daemon/daemon.go +++ b/hive/daemon/daemon.go @@ -493,6 +493,12 @@ func (d *Daemon) Start() error { } } + // Create services before loading/launching instances, since LaunchInstance depends on them + d.instanceService = handlers_ec2_instance.NewInstanceServiceImpl(d.config, d.resourceMgr.instanceTypes, d.natsConn, &d.Instances) + d.keyService = handlers_ec2_key.NewKeyServiceImpl(d.config) + d.imageService = handlers_ec2_image.NewImageServiceImpl(d.config) + d.volumeService = handlers_ec2_volume.NewVolumeServiceImpl(d.config) + // Load existing state for VMs from JetStream or disk err = d.LoadState() if err != nil { @@ -541,18 +547,6 @@ func (d *Daemon) Start() error { } - // Create instance service for handling EC2 instance operations - d.instanceService = handlers_ec2_instance.NewInstanceServiceImpl(d.config, d.resourceMgr.instanceTypes, d.natsConn, &d.Instances) - - // Create key service for handling EC2 key pair operations - d.keyService = handlers_ec2_key.NewKeyServiceImpl(d.config) - - // Create image service for handling EC2 AMI operations - d.imageService = handlers_ec2_image.NewImageServiceImpl(d.config) - - // Create volume service for handling EC2 EBS volume operations - d.volumeService = handlers_ec2_volume.NewVolumeServiceImpl(d.config) - log.Printf("Subscribing to subject pattern: %s", "ec2.launch") // Subscribe to EC2 events with queue group (legacy topic for backward compatibility)