Permalink
Browse files

feat(): command timeout

  • Loading branch information...
Izak88 authored and jkuri committed Sep 11, 2017
1 parent 8a1e51a commit 641d3fd4789c429501d91b99ba1452e80b7e79da
Showing with 12 additions and 2 deletions.
  1. +3 −1 src/api/process-manager.ts
  2. +7 −1 src/api/process.ts
  3. +2 −0 src/api/utils.ts
@@ -206,7 +206,9 @@ export function startJob(proc: JobProcess): Promise<void> {
}
});

startBuildProcess(proc, 'abstruse', envVariables)
const jobTimeout = config.jobTimeout ? config.jobTimeout * 1000 : 3600000;
const idleTimeout = config.idleTimeout ? config.idleTimeout * 1000 : 3600000;
startBuildProcess(proc, 'abstruse', envVariables, jobTimeout, idleTimeout)
.subscribe(event => {
const msg: JobProcessEvent = {
build_id: proc.build_id,
@@ -31,7 +31,9 @@ export interface ProcessOutput {
export function startBuildProcess(
proc: JobProcess,
image: string,
variables: string[]
variables: string[],
jobTimeout: number,
idleTimeout: number
): Observable<ProcessOutput> {
return new Observable(observer => {
const name = 'abstruse_' + proc.build_id + '_' + proc.job_id;
@@ -124,6 +126,10 @@ export function startBuildProcess(
.concat(...[saveCache])
.concat(...scriptCommands.map(cmd => executeInContainer(name, cmd)))
.concat(...deployCommands.map(cmd => executeInContainer(name, cmd)))
.timeoutWith(idleTimeout, Observable.throw(new Error('command timeout')))
.merge(Observable.timer(jobTimeout).timeInterval().mergeMap((): any => {
Observable.throw('job timeout');
}))
.subscribe((event: ProcessOutput) => {
observer.next(event);
}, err => {
@@ -24,6 +24,8 @@ const defaultConfig = {
port: 6500,
wsport: 6501,
concurrency: 10,
idleTimeout: 600,
jobTimeout: 3600,
ssl: false,
sslcert: null,
sslkey: null,

0 comments on commit 641d3fd

Please sign in to comment.