experiment: tasks

This commit is contained in:
Manuel committed 2026-03-25 19:46:10 +00:00
1 parent 5a81d035cf
commit 4192cdaa6e
24 files changed
+384 -305

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
const http = require('http');
function triggerJobs() {
const options = {
hostname: 'localhost',
port: 3000,
path: '/api/internal/trigger-jobs',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-internal-request': 'true'
}
};
const req = http.request(options, (res) => {
if (res.statusCode !== 200) {
console.error(`Failed to trigger jobs: ${res.statusCode}`);
}
});
req.on('error', (err) => {
console.error('Error triggering jobs:', err);
});
req.end();
}
// Trigger jobs every second
setInterval(triggerJobs, 1000);
// Initial trigger
triggerJobs();
+8 -1
View File
@@ -54,10 +54,17 @@ WSS_PID=$!
node apps/nextjs/server.js &
NEXTJS_PID=$!
# Wait a bit for NextJS to start
sleep 5
# Start job scheduler
node scripts/job-scheduler.js &
SCHEDULER_PID=$!
# Function to handle SIGTERM and shut down services
terminate() {
echo "Received SIGTERM. Shutting down..."
kill -TERM $NGINX_PID $TASKS_PID $WSS_PID $NEXTJS_PID 2>/dev/null
kill -TERM $NGINX_PID $SCHEDULER_PID $WSS_PID $NEXTJS_PID 2>/dev/null
wait
# kill redis-server last because of logging of other services and only if $REDIS_PID is set
if [ -n "$REDIS_PID" ]; then