()
| 3541 | } |
| 3542 | |
| 3543 | func (d *integrationDaemon) spawnDetached() (daemonProcess, error) { |
| 3544 | d.mu.Lock() |
| 3545 | defer d.mu.Unlock() |
| 3546 | if d.running { |
| 3547 | return nil, errors.New("integration daemon already running") |
| 3548 | } |
| 3549 | |
| 3550 | ctx, cancel := context.WithCancel(context.Background()) |
| 3551 | waitCh := make(chan error, 1) |
| 3552 | done := make(chan struct{}) |
| 3553 | d.running = true |
| 3554 | d.cancel = cancel |
| 3555 | d.done = waitCh |
| 3556 | |
| 3557 | go func() { |
| 3558 | err := d.Run(ctx) |
| 3559 | waitCh <- err |
| 3560 | close(waitCh) |
| 3561 | close(done) |
| 3562 | d.mu.Lock() |
| 3563 | d.running = false |
| 3564 | d.cancel = nil |
| 3565 | d.done = nil |
| 3566 | d.mu.Unlock() |
| 3567 | }() |
| 3568 | |
| 3569 | return &integrationDaemonProcess{pid: d.pid, done: done, waitCh: waitCh}, nil |
| 3570 | } |
| 3571 | |
| 3572 | func (d *integrationDaemon) Run(ctx context.Context) error { |
| 3573 | registry, err := globaldb.OpenGlobalDB(context.Background(), d.homePaths.DatabaseFile) |
no test coverage detected