experiment: tasks
This commit is contained in:
1 parent
d4e4c9669d
commit
718b03cdb3
24 files changed
+385
-305
No files matched your search
@@ -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
@@ -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
|
||||
|
||||
Reference in new issue
Block a user