fix: Cancel jobs
This commit is contained in:
		| @@ -22,16 +22,17 @@ export const post: RequestHandler = async (event) => { | |||||||
| 			} = job.data; | 			} = job.data; | ||||||
| 			const host = getEngine(engine); | 			const host = getEngine(engine); | ||||||
| 			let interval = setInterval(async () => { | 			let interval = setInterval(async () => { | ||||||
| 				const { status } = await db.prisma.build.findUnique({ where: { id: buildId } }); | 				try { | ||||||
| 				if (status === 'failed') { | 					const data = await db.prisma.build.findUnique({ where: { id: buildId } }); | ||||||
|  | 					if (data?.status === 'failed') { | ||||||
| 						clearInterval(interval); | 						clearInterval(interval); | ||||||
| 						return resolve(); | 						return resolve(); | ||||||
| 					} | 					} | ||||||
| 				if (count > 1200) { | 					if (count > 60) { | ||||||
| 						clearInterval(interval); | 						clearInterval(interval); | ||||||
| 						reject(new Error('Could not cancel build.')); | 						reject(new Error('Could not cancel build.')); | ||||||
| 					} | 					} | ||||||
| 				try { |  | ||||||
| 					const { stdout: buildContainers } = await asyncExecShell( | 					const { stdout: buildContainers } = await asyncExecShell( | ||||||
| 						`DOCKER_HOST=${host} docker container ls --filter "label=coolify.buildId=${buildId}" --format '{{json .}}'` | 						`DOCKER_HOST=${host} docker container ls --filter "label=coolify.buildId=${buildId}" --format '{{json .}}'` | ||||||
| 					); | 					); | ||||||
| @@ -53,7 +54,7 @@ export const post: RequestHandler = async (event) => { | |||||||
| 					} | 					} | ||||||
| 					count++; | 					count++; | ||||||
| 				} catch (error) {} | 				} catch (error) {} | ||||||
| 			}, 100); | 			}, 1000); | ||||||
|  |  | ||||||
| 			resolve(); | 			resolve(); | ||||||
| 		}); | 		}); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Andras Bacsai
					Andras Bacsai