mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-10 01:06:17 +00:00
docs: update scheduling instructions in Docker and setup documentation
This commit is contained in:
@@ -190,102 +190,6 @@ tail -100 /var/log/cron.log
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**[← Back to Hub](index.md)** | **[Getting Started](getting-started.md)**# 🐳 Docker Guide
|
|
||||||
|
|
||||||
**Run the script in a container**
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ⚡ Quick Start
|
|
||||||
|
|
||||||
### 1. Create Required Files
|
|
||||||
|
|
||||||
Ensure you have:
|
|
||||||
- `src/accounts.jsonc` with your credentials
|
|
||||||
- `src/config.jsonc` (uses defaults if missing)
|
|
||||||
|
|
||||||
### 2. Start Container
|
|
||||||
|
|
||||||
## 🎛️ Scheduling Options
|
|
||||||
|
|
||||||
### Use a host scheduler (recommended)
|
|
||||||
|
|
||||||
- Trigger `docker compose up --build` on your preferred schedule (cron, systemd timers, Task Scheduler, Kubernetes CronJob, etc.).
|
|
||||||
- Ensure volumes remain consistent so each run reuses accounts, config, and sessions.
|
|
||||||
- See [External Scheduling](schedule.md) for concrete host examples.
|
|
||||||
|
|
||||||
### Enable in-container cron (optional)
|
|
||||||
|
|
||||||
1. Set environment variables in `docker-compose.yml` or `docker run`:
|
|
||||||
build: .
|
|
||||||
environment:
|
|
||||||
TZ: "Europe/Paris"
|
|
||||||
command: ["npm", "run", "start:schedule"]
|
|
||||||
```
|
|
||||||
|
|
||||||
Configure schedule in `src/config.jsonc`:
|
|
||||||
```jsonc
|
|
||||||
{
|
|
||||||
"schedule": {
|
|
||||||
"enabled": true,
|
|
||||||
"useAmPm": false,
|
|
||||||
"time24": "09:00",
|
|
||||||
"timeZone": "Europe/Paris"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Option 2: Native Cron (For Traditional Cron Users)
|
|
||||||
|
|
||||||
**Pros:**
|
|
||||||
- ✅ Familiar cron syntax
|
|
||||||
- ✅ Multiple daily runs with standard crontab
|
|
||||||
- ✅ Native Linux scheduling
|
|
||||||
|
|
||||||
**Setup:**
|
|
||||||
|
|
||||||
1. **Enable cron in `docker-compose.yml`:**
|
|
||||||
```yaml
|
|
||||||
services:
|
|
||||||
rewards:
|
|
||||||
build: .
|
|
||||||
environment:
|
|
||||||
TZ: "Europe/Paris"
|
|
||||||
USE_CRON: "true"
|
|
||||||
CRON_SCHEDULE: "0 9,16,21 * * *" # 9 AM, 4 PM, 9 PM daily
|
|
||||||
RUN_ON_START: "true" # Optional: run once on start
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Cron Schedule Examples:**
|
|
||||||
|
|
||||||
| Schedule | Description | Cron Expression |
|
|
||||||
|----------|-------------|-----------------|
|
|
||||||
| Daily at 9 AM | Once per day | `0 9 * * *` |
|
|
||||||
| Twice daily | 9 AM and 9 PM | `0 9,21 * * *` |
|
|
||||||
| Three times | 9 AM, 4 PM, 9 PM | `0 9,16,21 * * *` |
|
|
||||||
| Every 6 hours | 4 times daily | `0 */6 * * *` |
|
|
||||||
| Weekdays only | Mon-Fri at 8 AM | `0 8 * * 1-5` |
|
|
||||||
|
|
||||||
**Use [crontab.guru](https://crontab.guru) to validate your cron expressions.**
|
|
||||||
|
|
||||||
3. **Rebuild and restart:**
|
|
||||||
```bash
|
|
||||||
docker compose down
|
|
||||||
docker compose build --no-cache
|
|
||||||
docker compose up -d
|
|
||||||
```
|
|
||||||
|
|
||||||
4. **Verify cron is running:**
|
|
||||||
```bash
|
|
||||||
# Check container logs
|
|
||||||
docker logs -f microsoft-rewards-bot
|
|
||||||
|
|
||||||
# Should see: "==> Cron mode enabled"
|
|
||||||
|
|
||||||
# View cron logs inside container
|
|
||||||
docker exec microsoft-rewards-bot tail -f /var/log/cron.log
|
|
||||||
```
|
|
||||||
|
|
||||||
### Option 3: Single Run (Manual)
|
### Option 3: Single Run (Manual)
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
BIN
docs/schedule.md
BIN
docs/schedule.md
Binary file not shown.
@@ -154,8 +154,8 @@ async function fullSetup() {
|
|||||||
if (['yes', 'y'].includes(start)) {
|
if (['yes', 'y'].includes(start)) {
|
||||||
await runCommand(process.platform === 'win32' ? 'npm.cmd' : 'npm', ['run', 'start']);
|
await runCommand(process.platform === 'win32' ? 'npm.cmd' : 'npm', ['run', 'start']);
|
||||||
} else {
|
} else {
|
||||||
log('\nFinished setup. To start later, run: npm start');
|
log('\nFinished setup. To start later, run: npm start');
|
||||||
log('For automated scheduling, run: npm run start:schedule');
|
log('For automated scheduling, use your OS scheduler (see docs/schedule.md).');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user