Skip to content

Commit

Permalink
feat(config): read concurrency from config file
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Jun 12, 2017
1 parent 6214dff commit 792038a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/api/process-manager.ts
Expand Up @@ -7,6 +7,7 @@ import { getRepositoryDetails, generateCommands } from './config';
import { killContainer } from './docker';
import * as logger from './logger';
import { blue, yellow, green, cyan } from 'chalk';
import { getConfig } from './utils';

export interface BuildMessage {
type: string;
Expand Down Expand Up @@ -37,6 +38,7 @@ export interface JobProcessEvent {
data?: string;
}

const config: any = getConfig();
let queueBlocked: boolean;
export let jobProcesses: JobProcess[] = [];
export let jobEvents: BehaviorSubject<JobProcessEvent> = new BehaviorSubject({});
Expand All @@ -54,9 +56,8 @@ jobEvents
Observable.interval(1000)
.map(() => {
if (this.queueBlocked) { return; }

let runningJobs = jobProcesses.filter(jp => jp.status === 'running').length;
let parallelJobsAvailable = 2;
let parallelJobsAvailable = config.concurrency;
if (runningJobs < parallelJobsAvailable) {
let newJobProcesses = jobProcesses.filter(jp => jp.status === 'queued');
if (newJobProcesses.length) {
Expand Down
1 change: 1 addition & 0 deletions src/api/utils.ts
Expand Up @@ -9,6 +9,7 @@ import * as uuid from 'uuid';
const defaultConfig = {
port: 6500,
wsport: 6501,
concurrency: 10,
db: {
client: 'sqlite3',
connection: {
Expand Down
8 changes: 7 additions & 1 deletion src/app/components/app-setup/app-setup.component.ts
Expand Up @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ApiService } from '../../services/api.service';
import { SocketService } from '../../services/socket.service';
import { AuthService } from '../../services/auth.service';

export interface ServerStatus {
sqlite: boolean;
Expand Down Expand Up @@ -33,7 +34,8 @@ export class AppSetupComponent implements OnInit {
constructor(
private apiService: ApiService,
private socketService: SocketService,
private router: Router
private router: Router,
private authService: AuthService
) {
this.serverStatus = {
sqlite: false,
Expand All @@ -52,6 +54,10 @@ export class AppSetupComponent implements OnInit {
if (event) {
this.router.navigate(['/login']);
} else {
if (this.authService.isLoggedIn()) {
this.authService.logout();
}

this.checkConfiguration();
}
});
Expand Down

0 comments on commit 792038a

Please sign in to comment.