Skip to content

Commit 546cf7c

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 de09939 commit 546cf7c

6 files changed

Lines changed: 20 additions & 2 deletions

File tree

backend/README.md

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

8383
### Database Location
8484

85-
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.
85+
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.
8686

8787
- Run the application:
8888

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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ REDIRECT_URL_DEV="http://localhost:8000/auth/callback"
99
SESSION_KEY="generate a secret key using 'openssl rand -hex 32'"
1010
FRONTEND_ORIGIN_DEV="http://localhost" # URL of the web frontend to avoid CORS errors
1111
CONTAINER_ORIGIN="http://YOUR_CONTAINER_NAME:8080/" # Deployed taskchampion-sync-server container, default is production-syncserver-1
12+
13+
# Job Queue Configuration (optional, defaults shown)
14+
CLEANUP_CRON_SCHEDULE="0 0 * * *" # Daily at midnight
15+
CLEANUP_RETENTION_DAYS="7" # Keep logs for 7 days
16+
QUEUE_DB_PATH="/app/data/queue.db" # Queue database location, mounted via Docker volume
1217
```
1318

1419
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
@@ -5,3 +5,8 @@ CLIENT_ID="Via Google Oauth"
55
FRONTEND_ORIGIN_DEV="http://localhost"
66
CONTAINER_ORIGIN="http://production-syncserver-1:8080/"
77
PORT=8000
8+
9+
# Job Queue Configuration
10+
CLEANUP_CRON_SCHEDULE="0 0 * * *"
11+
CLEANUP_RETENTION_DAYS="7"
12+
QUEUE_DB_PATH="/app/data/queue.db"

0 commit comments

Comments
 (0)