Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/con/ drwxr-xr-x | |
| Viewing file: Select action/file-type: const Bull = require('bull');
const Redis = require('ioredis');
// Extract host and password from Upstash URL
const UPSTASH_REDIS_URL = "rediss://default:AYZTAAIjcDEwZjllMzMxMTEwN2Q0MmJlYTExMjllN2RmMjQzZTlmOXAxMA@solid-bull-34387.upstash.io:6379"; // Format: redis://<username>:<password>@<host>:6379
const url = new URL(UPSTASH_REDIS_URL);
const redisOptions = {
host: url.hostname,
port: parseInt(url.port, 10),
password: url.password,
tls: {
rejectUnauthorized: false, // Required for Upstash
},
};
// Create a Bull queue with a custom Redis client
const myQueue = new Bull('my-queue', {
createClient: (type) => {
console.log(`Creating Redis client for: ${type}`);
switch (type) {
case 'client':
return new Redis(redisOptions);
case 'subscriber':
return new Redis({
...redisOptions,
enableReadyCheck: false, // Disable ready check for subscribers
});
case 'bclient':
return new Redis({
...redisOptions,
maxRetriesPerRequest: null, // No retries for blocking commands
});
default:
throw new Error(`Unexpected Redis client type: ${type}`);
}
},
});
// // Add jobs to the queue
myQueue.add({ task: 'send_email', to: 'user@example.com' }) .then(() => {
console.log('Job added to the queue');
})
.catch((err) => {
console.error('Error adding job:', err);
});
// // Process jobs
myQueue.process(async (job) => {
console.log("proceeeeeeeeeeeeeeesssssssssss");
// console.log(`Processing job: ${JSON.stringify(job.data)}`);
});
// myQueue.on('completed', (job) => {
// console.log(`Job completed: ${job.id}`);
// });
// myQueue.on('failed', (job, err) => {
// console.error(`Job failed: ${job.id} - ${err.message}`);
// });
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0051 ]-- |