Skip to content

Commit 24d32f8

Browse files
committed
fix: job doubling bug and add queue config to production
Fixed job restoration to prevent duplicates and added queue environment variables to production files for Docker/Kubernetes deployments.
1 parent 61e0c69 commit 24d32f8

6 files changed

Lines changed: 21 additions & 3 deletions

File tree

backend/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ The job queue system uses the following environment variables:
110110

111111
### Database Location
112112

113-
The queue database is stored at `/app/data/queue.db` inside the container, which is mounted to `./backend/data/queue.db` on the host system via Docker volume.
113+
The queue database is stored at `/app/data/queue.db` inside the container, which is mounted to `./backend/data/queue.db` on the host system via Docker volume. The `QUEUE_DB_PATH` environment variable can be used to customize this location if needed.
114114

115115
- Run the application:
116116

backend/controllers/job_queue.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ func (q *JobQueue) restorePendingJobs() {
119119
return nil
120120
},
121121
}
122-
q.AddJob(job)
122+
q.wg.Add(1)
123+
go func(j Job) {
124+
q.jobChannel <- j
125+
}(job)
123126
}
124127
}
125128
func (q *JobQueue) GetPersistentQueue() utils.PersistentJobQueue {

backend/utils/persistent_queue.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"go.etcd.io/bbolt"
1111
)
1212

13+
// IMP ==> JobState and PersistentJob remain in utils due to import cycle with models/logs.go
14+
1315
type JobState string
1416

1517
const (

production/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ CLIENT_SEC="client_SECRET" # Google Auth Secret from Prerequisites
1010
REDIRECT_URL_DEV="http://localhost:8000/auth/callback"
1111
SESSION_KEY="generate a secret key using 'openssl rand -hex 32'"
1212
FRONTEND_ORIGIN_DEV="http://localhost" # URL of the web frontend to avoid CORS errors
13-
CONTAINER_ORIGIN="http://production-syncserver-1:8080/" # Deployed taskchampion-sync-server container
13+
CONTAINER_ORIGIN="http://YOUR_CONTAINER_NAME:8080/" # Deployed taskchampion-sync-server container, default is production-syncserver-1
14+
15+
# Job Queue Configuration (optional, defaults shown)
16+
CLEANUP_CRON_SCHEDULE="0 0 * * *" # Daily at midnight
17+
CLEANUP_RETENTION_DAYS="7" # Keep logs for 7 days
18+
QUEUE_DB_PATH="/app/data/queue.db" # Queue database location, mounted via Docker volume
1419
```
1520

1621
2. Run `docker-compose pull` to pull the CCSync images.

production/backend-env-configmap.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ data:
77
PORT: "8000"
88
REDIRECT_URL_DEV: http://localhost:8000/auth/callback
99
SESSION_KEY: u2IBgLagrov1Q2fi0b9o/UNpYsJMDYP5dOLWQyDZRas= # Can also generate your own and replace, using 'openssl rand -hex 32'
10+
CLEANUP_CRON_SCHEDULE: "0 0 * * *"
11+
CLEANUP_RETENTION_DAYS: "7"
12+
QUEUE_DB_PATH: "/app/data/queue.db"
1013
kind: ConfigMap
1114
metadata:
1215
labels:

production/example.backend.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@ CONTAINER_ORIGIN="http://syncserver:8080/"
1818

1919
# Port (usually 8000)
2020
PORT=8000
21+
22+
# Job Queue Configuration
23+
CLEANUP_CRON_SCHEDULE="0 0 * * *"
24+
CLEANUP_RETENTION_DAYS="7"
25+
QUEUE_DB_PATH="/app/data/queue.db"

0 commit comments

Comments
 (0)