Ana içeriğe geç

Cron Jobs & Queue Workers

FeedbackPulse SaaS uses Laravel's task scheduler for automated background work. Setting up the cron gorevi is essential for full functionality.


The Cron Job (Required)

What It Does

The cron gorevi runs Laravel's scheduler every minute. The scheduler then decides which tasks to execute based on their configured frequency:

TaskFrequencyWhat It Does
feedbackpulse:trial-expiryEvery 6 hoursRestricts tenants whose free trial has ended without a paid plan
feedbackpulse:usage-alertsDaily at 9:00 AMSends email alerts to tenants approaching their plan's submission limit (90%+)
data:enforce-retentionDaily at 2:00 AMDeletes or anonymizes old submissions per veri saklama policy
digest:sendDaily at 8:00 AMSends daily/weekly e-posta ozetis to tenant admins
reports:send-scheduledDaily at 7:00 AMSends zamanlanmis raporlar (daily/weekly/monthly)
ai:detect-anomaliesEvery 12 hoursAI-powered detection of unusual rating patterns

Setting It Up

# Open the crontab editor
crontab -e

Add this single line:

* * * * * cd /var/www/feedbackpulse-saas && php artisan schedule:run >> /dev/null 2>&1

Explanation:

  • * * * * * — run every minute
  • cd /var/www/feedbackpulse-saas — navigate to your project
  • php artisan schedule:run — Laravel checks which tasks are due
  • >> /dev/null 2>&1 — discard output (logs go to Laravel's log file)

Verify It's Running

# List cron jobs
crontab -l

# Run manually to test
cd /var/www/feedbackpulse-saas
php artisan schedule:run

# Check the cron logs in the database (admin panel -> Settings)

cPanel Cron Setup

If you're on paylasimli hosting with cPanel:

  1. Su adrese gidin cPanel → Cron Jobs
  2. Set "Common Ayarlar" to Once Per Minute
  3. In the "Command" field, enter:
cd /home/username/feedbackpulse-saas && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1

Not: On cPanel, the PHP binary path might be /usr/local/bin/php or /usr/bin/php. Check with which php.

URL-Based Cron (Shared Hosting Alternative)

If your hosting panel only supports URL/wget-based cron (no CLI commands), FeedbackPulse includes a built-in web endpoint:

https://yourdomain.com/cron/run?token=YOUR_CRON_TOKEN

Setup:

  1. Your CRON_TOKEN is auto-generated during installation and shown on the completion page
  2. You can also find it in your .env file: CRON_TOKEN=your_token_here
  3. In your hosting panel's cron manager, add a new job:
    • Frequency: Every minute (or every 5 minutes)
    • Type: URL / wget / curl
    • URL or Command:
    wget -q -O /dev/null "https://yourdomain.com/cron/run?token=YOUR_CRON_TOKEN"
    Or with curl:
    curl -s "https://yourdomain.com/cron/run?token=YOUR_CRON_TOKEN" > /dev/null 2>&1

Guvenlik: The CRON_TOKEN is a 64-character random hex string. Without it, the endpoint returns 403 Forbidden. Never share this token publicly.

Where to find your token: Check the .env file for the CRON_TOKEN= line, or re-generate one by running php artisan tinker and entering bin2hex(random_bytes(32)), then updating .env.

HestiaCP / CyberPanel / CloudPanel

Most server panels have a "Cron Jobs" section:

  1. Su adrese gidin your panel's cron manager
  2. Add a new cron gorevi with the schedule * * * * *
  3. Enter the command: cd /var/www/feedbackpulse-saas && php artisan schedule:run >> /dev/null 2>&1
  4. Or if your panel supports URL-based cron, use the URL method described above

By default, FeedbackPulse runs all jobs synchronously (inline with the web request). This is fine for small installations. For better performance at scale, you can run a queue worker.

When You Need a Queue Worker

  • You have 50+ tenants
  • Email sending is slow (blocks the UI)
  • Webhook delivery is slow
  • AI analysis takes too long

The Default Setup: Synchronous

In .env:

QUEUE_CONNECTION=sync

All jobs run immediately during the HTTP request. Simple but slower.

Upgrading to Veritabani Queue

  1. Update .env:
QUEUE_CONNECTION=database
  1. The queue table is already created by migrations. Start the worker:
# Start a queue worker
php artisan queue:work --sleep=3 --tries=3 --max-time=3600
  1. To keep it running permanently, use Supervisor:
sudo apt install supervisor
sudo nano /etc/supervisor/conf.d/feedbackpulse-worker.conf
[program:feedbackpulse-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/feedbackpulse-saas/artisan queue:work database --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www-data
numprocs=2
redirect_stderr=true
stdout_logfile=/var/www/feedbackpulse-saas/storage/logs/worker.log
stopwaitsecs=3600
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start feedbackpulse-worker:*

Upgrading to Redis Queue (Best Performance)

  1. Install Redis:
sudo apt install redis-server php8.2-redis
  1. Update .env:
QUEUE_CONNECTION=redis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
  1. Set up Supervisor (same as above, replace database with redis in the command)

Monitoring

Check Cron Execution

FeedbackPulse logs all cron executions to the cron_logs database table. You can view these in the yonetim paneli.

Check Queue Status

# See pending jobs
php artisan queue:monitor database:default

# See failed jobs
php artisan queue:failed

# Retry a failed job
php artisan queue:retry {job-id}

# Retry all failed jobs
php artisan queue:retry all

Sonraki Adimlar