-
-
Notifications
You must be signed in to change notification settings - Fork 4
Troubleshooting
Comprehensive troubleshooting guide for common issues, error resolution, and maintenance procedures for Source-License.
Error:
Source-License requires Ruby 3.4.7 or higher. Current version: 2.7.0
Solution:
-
Install correct Ruby version:
# Using rbenv (recommended) rbenv install 3.4.7 rbenv global 3.4.7 rbenv rehash # Using RVM rvm install 3.4.7 rvm use 3.4.7 --default # Verify installation ruby --version
-
Update PATH if necessary:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc source ~/.bashrc
Error:
An error occurred while installing mysql2 (0.5.4), and Bundler cannot continue.
Solutions:
For MySQL on Ubuntu/Debian:
sudo apt-get update
sudo apt-get install libmysqlclient-dev build-essential
bundle installFor MySQL on macOS:
brew install mysql
bundle installFor PostgreSQL issues:
# Ubuntu/Debian
sudo apt-get install libpq-dev
# macOS
brew install postgresqlError:
Sequel::DatabaseConnectionError: Access denied for user 'root'@'localhost'
Solutions:
-
Check database credentials in
.env:DATABASE_ADAPTER=mysql DATABASE_HOST=localhost DATABASE_PORT=3306 DATABASE_NAME=source_license DATABASE_USER=your_username DATABASE_PASSWORD=your_password
-
Verify database server is running:
# MySQL sudo systemctl status mysql sudo systemctl start mysql # PostgreSQL sudo systemctl status postgresql sudo systemctl start postgresql
-
Create database and user manually:
-- MySQL CREATE DATABASE source_license CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'source_license'@'localhost' IDENTIFIED BY 'secure_password'; GRANT ALL PRIVILEGES ON source_license.* TO 'source_license'@'localhost'; FLUSH PRIVILEGES; -- PostgreSQL CREATE DATABASE source_license; CREATE USER source_license WITH PASSWORD 'secure_password'; GRANT ALL PRIVILEGES ON DATABASE source_license TO source_license;
Error:
Address already in use - bind(2) for "127.0.0.1" port 4567
Solutions:
-
Find and kill process using port:
# Find process using port 4567 lsof -ti:4567 # Kill the process kill -9 $(lsof -ti:4567) # Or use a different port APP_PORT=4568 ruby launch.rb
-
Check for multiple instances:
ps aux | grep ruby # Kill any existing Source-License processes
Error:
APP_SECRET must be set in production
Solution:
# Check .env file exists and contains required variables
cat .env
# Copy from example if missing
cp .env.example .env
# Edit with your specific values
nano .envRequired variables:
APP_SECRET=your_very_long_secret_key_at_least_64_characters_long_for_security
JWT_SECRET=another_secret_key_for_jwt_tokens
DATABASE_ADAPTER=mysql
DATABASE_HOST=localhost
DATABASE_NAME=source_license
DATABASE_USER=username
DATABASE_PASSWORD=password
ADMIN_EMAIL=admin@yourdomain.com
ADMIN_PASSWORD=secure_admin_passwordError:
Stripe::AuthenticationError: Invalid API Key provided
Solutions:
-
Verify Stripe API keys:
STRIPE_PUBLISHABLE_KEY=pk_live_... (or pk_test_... for testing) STRIPE_SECRET_KEY=sk_live_... (or sk_test_... for testing) STRIPE_WEBHOOK_SECRET=whsec_...
-
Check Stripe webhook configuration:
-
Endpoint URL:
https://yourdomain.com/api/webhook/stripe -
Events:
payment_intent.succeeded,payment_intent.payment_failed -
Webhook secret: Must match
STRIPE_WEBHOOK_SECRETin.env
-
Endpoint URL:
-
Test Stripe connection:
# In Rails console or test script require 'stripe' Stripe.api_key = ENV['STRIPE_SECRET_KEY'] begin Stripe::Account.retrieve puts "Stripe connection successful" rescue => e puts "Stripe error: #{e.message}" end
Error:
PayPal::Exception::UnauthorizedAccess
Solutions:
-
Verify PayPal credentials:
PAYPAL_CLIENT_ID=your_paypal_client_id PAYPAL_CLIENT_SECRET=your_paypal_client_secret PAYPAL_ENVIRONMENT=sandbox # or production
-
Check PayPal webhook settings:
-
Webhook URL:
https://yourdomain.com/api/webhook/paypal -
Events:
PAYMENT.CAPTURE.COMPLETED,PAYMENT.CAPTURE.DENIED
-
Webhook URL:
Error:
License key generation failed: Duplicate entry
Solutions:
-
Check for license key conflicts:
# In admin console duplicate_keys = License.group(:license_key).having(Sequel.function(:count, :id) > 1) puts "Duplicate keys found: #{duplicate_keys.count}"
-
Regenerate conflicting licenses:
# Find and regenerate duplicate licenses License.where(license_key: 'DUPLICATE-KEY').each do |license| new_key = LicenseGenerator.generate_unique_key license.update(license_key: new_key) end
-
Check license format configuration:
# Verify license format settings puts SettingsManager.get('license.default_format') puts SettingsManager.get('license.default_max_activations')
Error:
{"valid": false, "error": "license_not_found"}
Debugging steps:
-
Verify license exists in database:
# Check database directly mysql -u username -p source_license SELECT * FROM licenses WHERE license_key = 'YOUR-LICENSE-KEY';
-
Check API endpoint accessibility:
curl -v http://localhost:4567/api/license/TEST-KEY/validate
-
Review application logs:
tail -f logs/application.log tail -f logs/error.log
Error:
Net::SMTPAuthenticationError: 535 Authentication failed
Solutions:
-
Verify SMTP settings:
SMTP_HOST=smtp.gmail.com SMTP_PORT=587 SMTP_USERNAME=your_email@gmail.com SMTP_PASSWORD=your_app_password # Not your regular password! SMTP_TLS=true
-
For Gmail, use App Passwords:
- Enable 2-factor authentication
- Generate App Password in Google Account settings
- Use App Password in
SMTP_PASSWORD
-
Test SMTP connection:
require 'mail' Mail.defaults do delivery_method :smtp, { address: ENV['SMTP_HOST'], port: ENV['SMTP_PORT'].to_i, user_name: ENV['SMTP_USERNAME'], password: ENV['SMTP_PASSWORD'], authentication: 'plain', enable_starttls_auto: true } end # Test email Mail.deliver do from ENV['SMTP_USERNAME'] to 'test@example.com' subject 'Test email' body 'This is a test email from Source-License' end
Debugging steps:
-
Check email delivery logs:
grep -i "email" logs/application.log grep -i "mail" logs/application.log
-
Verify email template exists:
ls -la views/emails/
-
Test manual email delivery:
# In admin panel or console license = License.first EmailService.send_license_email(license, 'test@example.com')
Symptoms:
- Slow response times
- Application crashes
- "Out of memory" errors
Solutions:
-
Monitor memory usage:
# Check system memory free -h # Check Ruby process memory ps aux | grep ruby top -p $(pgrep ruby)
-
Optimize database queries:
# Enable query logging DB.loggers = [Logger.new(STDOUT)] # Look for N+1 queries and optimize with eager loading licenses = License.eager(:product, :license_activations).all
-
Implement caching:
# Cache frequently accessed settings class SettingsCache def self.get(key) @cache ||= {} @cache[key] ||= SettingsManager.get_from_db(key) end end
Symptoms:
- Slow query responses
- High CPU usage
- Connection timeouts
Solutions:
-
Add database indexes:
-- Common indexes for Source-License CREATE INDEX idx_licenses_customer_email ON licenses(customer_email); CREATE INDEX idx_licenses_product_status ON licenses(product_id, status); CREATE INDEX idx_license_activations_machine ON license_activations(machine_fingerprint); CREATE INDEX idx_orders_created_at ON orders(created_at);
-
Optimize database configuration:
# MySQL optimization (/etc/mysql/my.cnf) [mysqld] innodb_buffer_pool_size = 1G innodb_log_file_size = 256M query_cache_type = 1 query_cache_size = 32M
-
Monitor slow queries:
-- MySQL SET GLOBAL slow_query_log = 'ON'; SET GLOBAL long_query_time = 2; -- Check slow query log SHOW VARIABLES LIKE 'slow_query_log_file';
Symptoms:
- Multiple failed login attempts in logs
- Account lockouts
- Suspicious IP addresses
Response procedures:
-
Review security logs:
grep -i "failed.*login" logs/security.log grep -i "authentication.*error" logs/application.log
-
Check for brute force attacks:
# Count failed attempts by IP grep "failed login" logs/security.log | awk '{print $5}' | sort | uniq -c | sort -nr
-
Block suspicious IPs:
# Using iptables sudo iptables -A INPUT -s SUSPICIOUS_IP -j DROP # Using fail2ban (recommended) sudo apt-get install fail2ban
-
Reset admin passwords:
# In console admin = Admin.first(email: 'admin@yourdomain.com') admin.password = 'new_secure_password' admin.save
Error:
SSL_ERROR_SSL: certificate verify failed
Solutions:
-
Check SSL certificate validity:
openssl x509 -in /path/to/certificate.crt -text -noout curl -vI https://yourdomain.com
-
Verify Nginx SSL configuration:
server { listen 443 ssl http2; server_name yourdomain.com; ssl_certificate /path/to/certificate.crt; ssl_certificate_key /path/to/private.key; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512; }
-
Force HTTPS in application:
configure :production do # Force HTTPS use Rack::SslEnforcer # Or in Sinatra settings set :force_ssl, true end
Location: logs/application.log
Common log patterns:
# Successful operations
grep "SUCCESS" logs/application.log
# License validations
grep "license.*validate" logs/application.log
# Payment processing
grep -i "payment" logs/application.log
# Database errors
grep -i "database.*error\|sequel.*error" logs/application.logLocation: logs/error.log
Critical error patterns:
# Application crashes
grep -i "fatal\|crash" logs/error.log
# Memory issues
grep -i "memory\|heap" logs/error.log
# Database connection issues
grep -i "connection.*failed\|timeout" logs/error.logLocation: logs/security.log
Security event patterns:
# Authentication events
grep -i "auth\|login" logs/security.log
# Failed access attempts
grep -i "unauthorized\|forbidden" logs/security.log
# Suspicious activities
grep -i "suspicious\|attack" logs/security.logCreate a simple health check script:
#!/usr/bin/env ruby
# health_check.rb
require_relative 'lib/database'
def check_database
DB.test_connection
puts "✓ Database connection: OK"
rescue => e
puts "✗ Database connection: FAILED - #{e.message}"
exit 1
end
def check_redis
# If using Redis
# Redis connection check
rescue => e
puts "✗ Redis connection: FAILED - #{e.message}"
end
def check_disk_space
usage = `df -h / | tail -1 | awk '{print $5}' | sed 's/%//'`.to_i
if usage > 90
puts "✗ Disk space: CRITICAL - #{usage}% used"
exit 1
else
puts "✓ Disk space: OK - #{usage}% used"
end
end
def check_memory
# Check available memory
mem_info = File.read('/proc/meminfo')
total = mem_info.match(/MemTotal:\s+(\d+)/)[1].to_i
available = mem_info.match(/MemAvailable:\s+(\d+)/)[1].to_i
usage = ((total - available) * 100.0 / total).round(1)
if usage > 90
puts "✗ Memory usage: CRITICAL - #{usage}%"
exit 1
else
puts "✓ Memory usage: OK - #{usage}%"
end
end
# Run checks
puts "Source-License Health Check"
puts "=" * 30
check_database
check_disk_space
check_memory
puts "All checks passed!"# Check API endpoints
curl -f http://localhost:4567/api/health || echo "API health check failed"
# Check license validation endpoint
curl -f http://localhost:4567/api/license/TEST-KEY/validate || echo "License API failed"-- MySQL performance queries
SHOW FULL PROCESSLIST;
SHOW ENGINE INNODB STATUS;
-- Check slow queries
SELECT * FROM mysql.slow_log ORDER BY start_time DESC LIMIT 10;
-- Check table sizes
SELECT
table_name,
round(((data_length + index_length) / 1024 / 1024), 2) AS 'Size (MB)'
FROM information_schema.tables
WHERE table_schema = 'source_license'
ORDER BY (data_length + index_length) DESC;# Add performance monitoring to critical endpoints
class PerformanceMonitor
def self.measure(operation_name)
start_time = Time.now
result = yield
duration = Time.now - start_time
log_performance(operation_name, duration)
result
end
private
def self.log_performance(operation, duration)
level = case duration
when 0..0.1 then 'INFO'
when 0.1..0.5 then 'WARN'
else 'ERROR'
end
Logger.new('logs/performance.log').send(
level.downcase.to_sym,
"#{operation}: #{duration.round(3)}s"
)
end
end
# Usage in controllers
post '/api/license/:key/activate' do
PerformanceMonitor.measure('license_activation') do
# Activation logic
end
endError:
mysqldump: Access denied for user 'backup'@'localhost'
Solutions:
-
Create backup user with proper permissions:
CREATE USER 'backup'@'localhost' IDENTIFIED BY 'secure_backup_password'; GRANT SELECT, LOCK TABLES, SHOW VIEW ON source_license.* TO 'backup'@'localhost'; FLUSH PRIVILEGES;
-
Test backup manually:
mysqldump -u backup -p source_license > backup_test.sql -
Automated backup script:
#!/bin/bash # backup.sh DATE=$(date +%Y%m%d_%H%M%S) BACKUP_DIR="/var/backups/source-license" DB_NAME="source_license" mkdir -p $BACKUP_DIR # Database backup mysqldump -u backup -p$DB_PASSWORD $DB_NAME | gzip > $BACKUP_DIR/db_$DATE.sql.gz # Application files backup tar -czf $BACKUP_DIR/files_$DATE.tar.gz /path/to/source-license --exclude=logs --exclude=tmp # Keep only last 30 days find $BACKUP_DIR -name "*.gz" -mtime +30 -delete echo "Backup completed: $DATE"
-
Stop application:
sudo systemctl stop source-license # or kill the Ruby process -
Restore database:
# Restore from SQL dump mysql -u root -p source_license < backup_20240115_120000.sql # Restore from compressed backup gunzip -c db_20240115_120000.sql.gz | mysql -u root -p source_license
-
Verify data integrity:
-- Check table counts SELECT COUNT(*) FROM users; SELECT COUNT(*) FROM licenses; SELECT COUNT(*) FROM orders; -- Check for orphaned records SELECT l.* FROM licenses l LEFT JOIN products p ON l.product_id = p.id WHERE p.id IS NULL;
-
Restart application:
ruby launch.rb # or sudo systemctl start source-license
When reporting issues, collect this information:
#!/bin/bash
# collect_diagnostics.sh
echo "Source-License Diagnostic Information"
echo "===================================="
echo "Date: $(date)"
echo "Hostname: $(hostname)"
echo ""
echo "System Information:"
echo "OS: $(lsb_release -d 2>/dev/null || cat /etc/os-release | grep PRETTY_NAME)"
echo "Ruby Version: $(ruby --version)"
echo "Bundler Version: $(bundle --version)"
echo ""
echo "Application Status:"
echo "Process: $(ps aux | grep -v grep | grep ruby | head -1)"
echo "Port 4567: $(lsof -ti:4567 2>/dev/null && echo 'In use' || echo 'Available')"
echo ""
echo "Database Connection:"
mysql -u $DATABASE_USER -p$DATABASE_PASSWORD -e "SELECT 1" 2>/dev/null && echo "MySQL: OK" || echo "MySQL: FAILED"
echo ""
echo "Disk Space:"
df -h /
echo ""
echo "Memory Usage:"
free -h
echo ""
echo "Recent Error Log:"
tail -20 logs/error.log 2>/dev/null || echo "No error log found"
echo ""
echo "Environment Variables:"
env | grep -E "(DATABASE|STRIPE|PAYPAL|SMTP)" | sed 's/=.*$/=***HIDDEN***/'-
GitHub Issues: For bugs and feature requests
- Include diagnostic information
- Provide minimal reproduction steps
- Include relevant log excerpts
-
GitHub Discussions: For questions and community support
- Search existing discussions first
- Provide context about your setup
-
Security Issues: Email security@pixelridgesoftworks.com
- Do not post security issues publicly
- Include detailed information about the vulnerability
-
Immediate Response:
# Check if system is completely down curl -f http://localhost:4567/ || echo "Application down" # Check process status ps aux | grep ruby # Check system resources free -h && df -h
-
Recovery Steps:
# Restart application cd /path/to/source-license ruby launch.rb # If database issues sudo systemctl restart mysql # If memory issues sudo systemctl restart source-license
-
Escalation:
- Document all error messages
- Collect diagnostic information
- Contact support with complete details
- Stop application immediately
- Restore from latest backup
- Run data integrity checks
- Test critical functionality
- Document the incident
This troubleshooting guide covers the most common issues encountered with Source-License. For additional support, refer to the GitHub Issues page or consult the Development Guide for technical implementation details.