3.8 KiB
3.8 KiB
Production Deployment Guide - Perizinan API Integration
🚀 Quick Deployment
1. Upload Files to Server
Upload semua files ke server Linux di directory /var/www/perling
(atau sesuai setup Anda).
2. Run Deployment Script
cd /var/www/perling
chmod +x deploy-production.sh
./deploy-production.sh
3. Update Environment Variables
Edit file .env
dan update:
APP_ENV=production
APP_DEBUG=false
# Database production
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=perling_production
DB_USERNAME=your_db_user
DB_PASSWORD=your_db_password
# API Credentials (yang sudah ada)
PERIZINAN_API_BEARER_TOKEN=f633c4f8e8a84708895bf31c0afdfa68c9079613d18d4edfb1fc6a0019b5f832
PERIZINAN_API_KEY=b06c8ef1-06db-443d-996b-80e8c3374923
4. Setup Cron Job
Option 1: Laravel Scheduler (Recommended)
# Edit crontab
sudo crontab -e
# Add this line (runs every minute):
* * * * * cd /var/www/perling && ./run-scheduler.sh >/dev/null 2>&1
Option 2: Direct Sync
# Edit crontab
sudo crontab -e
# Add this line (runs daily at midnight):
0 0 * * * cd /var/www/perling && ./sync-perizinan.sh >/dev/null 2>&1
🔧 Manual Commands
Test API Connection
cd /var/www/perling
php artisan perizinan:sync pertek
Check Synced Data
php artisan perizinan:check
View Logs
# Cron logs
tail -f storage/logs/cron.log
# Laravel application logs
tail -f storage/logs/laravel.log
# Scheduler logs (if using Option 1)
tail -f storage/logs/scheduler.log
View Cron Job Status
# View current crontab
crontab -l
# View cron service logs
sudo journalctl -u cron -f
🐛 Troubleshooting
Permission Issues
# Fix storage permissions
sudo chown -R www-data:www-data storage/
sudo chmod -R 775 storage/
# Fix cache permissions
sudo chown -R www-data:www-data bootstrap/cache/
sudo chmod -R 775 bootstrap/cache/
Database Issues
# Clear config cache
php artisan config:clear
# Run migrations
php artisan migrate --force
# Check database connection
php artisan tinker --execute="DB::connection()->getPdo();"
API Connection Issues
# Test API manually
curl -X GET "https://wsdev.jakarta.go.id/gateway/DataPerizinanLingkungan/1.0/summary_by_status?kategori=pertek" \
-H "Authorization: Bearer f633c4f8e8a84708895bf31c0afdfa68c9079613d18d4edfb1fc6a0019b5f832" \
-H "x-Gateway-APIKey: b06c8ef1-06db-443d-996b-80e8c3374923"
Cron Job Not Running
# Check if cron service is running
sudo systemctl status cron
# Start cron service if stopped
sudo systemctl start cron
# Check cron logs
sudo tail -f /var/log/cron.log
📊 Monitoring
Daily Health Check
# Check if data was synced today
php artisan perizinan:check
# Check latest logs
tail -20 storage/logs/cron.log
Weekly Review
# Check database records count
php artisan tinker --execute="echo App\Models\PerizinanStatus::count() . ' total records';"
# Check logs for errors
grep -i error storage/logs/laravel.log | tail -10
🔐 Security Notes
- File Permissions: Ensure proper permissions for Laravel
- Database: Use strong password and limit access
- API Keys: Keep credentials secure, don't commit to version control
- Logs: Regularly rotate and clean up log files
- SSL: Use HTTPS in production
📈 Performance Tips
- Database Indexing: Already added in migration
- Log Rotation: Setup logrotate for Laravel logs
- Caching: Enable OPcache for PHP
- Queue: Consider using Redis for Laravel queues if needed
🎯 Success Criteria
✅ Cron job runs without errors
✅ Data syncs daily at midnight
✅ Dashboard shows real API data
✅ Logs are clean without errors
✅ Database grows with daily records
✅ API connection is stable