feat: start worker in server

This commit is contained in:
Rohit Rajan
2025-09-10 00:20:18 +05:30
parent d92b62be00
commit b948ac9d9e
2 changed files with 6 additions and 5 deletions

View File

@@ -808,9 +808,6 @@ async function startWorkers() {
}
}
// Start all workers
startWorkers();
pgBoss.on('error', (error) => {
logger.log('error', `PgBoss error: ${error.message}`);
});
@@ -829,4 +826,4 @@ process.on('SIGINT', async () => {
});
// For use in other files
export { pgBoss };
export { pgBoss, startWorkers };

View File

@@ -20,7 +20,8 @@ import connectPgSimple from 'connect-pg-simple';
import pg from 'pg';
import session from 'express-session';
import Run from './models/Run';
import { processQueuedRuns } from './routes/storage';
import { processQueuedRuns, recoverOrphanedRuns } from './routes/storage';
import { startWorkers } from './pgboss-worker';
const app = express();
app.use(cors({
@@ -143,6 +144,9 @@ if (require.main === module) {
await connectDB();
await syncDB();
await recoverOrphanedRuns();
await startWorkers();
io = new Server(server);
io.of('/queued-run').on('connection', (socket) => {