feat: start worker in server
This commit is contained in:
@@ -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 };
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user