Merge pull request #401 from getmaxun/run-status
fix: Run status displays failed on system termination
This commit is contained in:
@@ -18,6 +18,7 @@ import { fork } from 'child_process';
|
|||||||
import { capture } from "./utils/analytics";
|
import { capture } from "./utils/analytics";
|
||||||
import swaggerUi from 'swagger-ui-express';
|
import swaggerUi from 'swagger-ui-express';
|
||||||
import swaggerSpec from './swagger/config';
|
import swaggerSpec from './swagger/config';
|
||||||
|
import Run from './models/Run';
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(cors({
|
app.use(cors({
|
||||||
@@ -113,8 +114,23 @@ server.listen(SERVER_PORT, '0.0.0.0', async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on('SIGINT', () => {
|
process.on('SIGINT', async () => {
|
||||||
console.log('Main app shutting down...');
|
console.log('Main app shutting down...');
|
||||||
|
try {
|
||||||
|
await Run.update(
|
||||||
|
{
|
||||||
|
status: 'failed',
|
||||||
|
finishedAt: new Date().toLocaleString(),
|
||||||
|
log: 'Process interrupted during execution - worker shutdown'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
where: { status: 'running' }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('Error updating runs:', error);
|
||||||
|
}
|
||||||
|
|
||||||
if (!isProduction) {
|
if (!isProduction) {
|
||||||
workerProcess.kill();
|
workerProcess.kill();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,9 +67,11 @@ async function jobCounts() {
|
|||||||
|
|
||||||
jobCounts();
|
jobCounts();
|
||||||
|
|
||||||
process.on('SIGINT', () => {
|
// We dont need this right now
|
||||||
console.log('Worker shutting down...');
|
|
||||||
process.exit();
|
// process.on('SIGINT', () => {
|
||||||
});
|
// console.log('Worker shutting down...');
|
||||||
|
// process.exit();
|
||||||
|
// });
|
||||||
|
|
||||||
export { workflowQueue, worker };
|
export { workflowQueue, worker };
|
||||||
Reference in New Issue
Block a user