Setting Up WhiskyPay Workers
This guide will walk you through the process of setting up and configuring the WhiskyPay Workers system for processing background jobs.Prerequisites
Before you begin, make sure you have:- Node.js (v16 or higher)
- Redis server (v6 or higher)
- A dedicated server/VM or container for running workers
- Email service credentials (if using email notifications)
Installation
1. Clone the Repository
2. Install Dependencies
3. Configure Environment Variables
Create a.env file in the project root:
- For Gmail, you’ll need to use an “app password” if you have 2FA enabled
- If your Redis server requires authentication, use:
redis://username:password@hostname:port
Redis Setup
Local Development
For local development, you can install Redis using:macOS
Linux
Windows
Download and install from Redis for WindowsDocker
Production Environment
For production, it’s recommended to:- Use a managed Redis service like Redis Labs, AWS ElastiCache, or Azure Cache for Redis
- Enable persistence to prevent job loss during restarts
- Configure proper authentication
- Set up monitoring
.env file with the production Redis URL:
Email Configuration
The email worker uses nodemailer with Gmail as the default provider. For production use:- Create a dedicated email account for sending notifications
- Enable “Less secure app access” or create an app password
- Update the
.envfile with the credentials
transporter configuration in index.ts:
Running the Workers
Development Mode
For development and testing:Production Mode
For production deployment:Process Management
For production deployments, use a process manager to ensure the workers stay running:PM2
Docker
A sample Dockerfile is provided:Monitoring
Basic Monitoring
Check the worker logs for errors and job processing:Advanced Monitoring
For production environments, consider setting up:- Log aggregation (ELK Stack, Graylog, etc.)
- Redis monitoring tools
- Worker health checks
- Alerting for failed jobs
Troubleshooting
Redis Connection Issues
If you see “Redis connection error” messages:- Verify Redis is running:
redis-cli pingshould returnPONG - Check connectivity:
telnet your-redis-host 6379 - Verify credentials if using authentication
- Check network/firewall settings
Email Sending Issues
If emails aren’t being sent:- Verify SMTP credentials
- Check for rate limiting by the email provider
- Ensure the email service is available
- Check logs for specific error messages
Job Processing Issues
If jobs aren’t being processed:- Check that Redis has enough memory allocated
- Verify job data format is correct
- Look for errors in the worker logs
- Ensure the worker process is running