Commit Graph

7 Commits

Author SHA1 Message Date
Wizznu 2f59a363da Optimize worker: reduce Firebase warnings and verbose logging 2026-02-11 07:49:29 +07:00
Wizznu 9b64706b4d Merge and update Railway Worker with fixes 2026-02-11 07:42:09 +07:00
Wizznu 8da7b66494 Initial commit: Railway Worker for ApsGo IoT System 2026-02-11 07:40:33 +07:00
Wizznu 59dc0b45d9 fix: Remove BOM from railway.json
Fixed Railway deployment error:
'invalid character ï looking for beginning of value'

Cause: UTF-8 BOM (Byte Order Mark) at file start
Solution: Recreated file with UTF-8 without BOM
Railway JSON parser now reads correctly
2026-02-10 11:37:34 +07:00
Wizznu 94499d02d5 feat: Add Dockerfile for Railway deployment
Added production-ready Dockerfile:
- Node.js 18 Alpine (lightweight)
- Multi-stage dependency installation
- Health check monitoring
- Non-root user for security
- Production optimizations

Added .dockerignore:
- Exclude node_modules (reinstalled in Docker)
- Exclude .env files (Railway injects env vars)
- Reduce image size
- Faster build times

Railway will now detect project type via Dockerfile instead of guessing from package.json.
This ensures proper build configuration for BullMQ worker.
2026-02-10 11:29:49 +07:00
Wizznu a9d894b2fd feat: ApsGo Railway Worker - 24/7 Background Automation
Complete Node.js worker for IoT automation:

Features:
- Waktu Mode: Time-based scheduling with cron
- Sensor Mode: Threshold-based automation
- BullMQ + Redis: Queue management (prevent race conditions)
- Firebase Admin: Realtime Database integration
- Auto History Logging: Every 10 minutes
- Health Monitoring: Auto-restart on failure
- Graceful Shutdown: Clean resource cleanup

Architecture:
- NO HTTP server (background worker only)
- Listen to Firebase Realtime DB changes
- Process jobs from Redis queue
- Execute scheduled tasks via cron

Tech Stack:
- Node.js 18+
- Firebase Admin SDK
- BullMQ (job queue)
- Redis (in-memory DB)
- IoRedis client

Files:
- worker.js: Main worker implementation (500+ lines)
- package.json: Dependencies and scripts
- railway.json: Railway deployment config (NO healthcheck - worker not HTTP)
- .env.example: Environment variables template
- README.md: Complete documentation
- .gitignore: Node modules, env files, logs

Ready for Railway deployment!
Connect to Redis and set Firebase environment variables.
2026-02-10 10:52:29 +07:00
awisnuu 8df97e29ec
Initial commit 2026-02-10 10:49:24 +07:00