示例#1
0
        public async Task <Build> StartBuildAsync(EngineLocatorType locatorType, string locator)
        {
            CheckDisposed();

            using (await _lock.ReaderLockAsync())
            {
                Engine engine = await _engineRepo.GetByLocatorAsync(locatorType, locator);

                if (engine == null)
                {
                    return(null);
                }
                EngineRunner runner = GetOrCreateRunner(engine.Id);
                return(await runner.StartBuildAsync(engine));
            }
        }
示例#2
0
        public async Task <bool> RemoveProjectAsync(string projectId)
        {
            CheckDisposed();

            using (await _lock.WriterLockAsync())
            {
                Engine engine = await _engineRepo.GetByProjectIdAsync(projectId);

                if (engine == null)
                {
                    return(false);
                }

                EngineRunner runner = GetOrCreateRunner(engine.Id);
                if (engine.Projects.Count == 1 && engine.Projects.Contains(projectId))
                {
                    // the engine will have no associated projects, so remove it
                    await _engineRepo.DeleteAsync(engine);

                    _runners.TryRemove(engine.Id, out _);
                    await runner.DeleteDataAsync();

                    runner.Dispose();
                }
                else
                {
                    // engine will still have associated projects, so just update it
                    await _engineRepo.ConcurrentUpdateAsync(engine, e => e.Projects.Remove(projectId));

                    await runner.StartBuildAsync(engine);
                }
                await _projectRepo.DeleteAsync(projectId);

                return(true);
            }
        }