filed
Job queue using FUSE
git clone git://mccd.space/filed
| Log | Files | Refs | README | LICENSE |
commit 175e737b059959acbdf15e012355753ee2353817 parent 556c14c3038d062a0caee9e66584813a59f2c971 Author: Marc Coquand <marc@coquand.email> Date: Mon, 15 Dec 2025 13:05:03 +0100 Enforce active jobs Diffstat:
| M | manager.go | | | 23 | +++++++++++++++++++++-- |
| M | qj.1.scd | | | 6 | +++--- |
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/manager.go b/manager.go
@@ -22,10 +22,24 @@ type ActiveJob struct {
}
func NewJobManager(s *store.Store) *JobManager {
+
return &JobManager{store: s}
}
func (jm *JobManager) StartWorker(ctx context.Context) {
+ jobs, err := jm.store.ListJobsByState(store.StateRunning)
+ if err != nil {
+ panic(err)
+ }
+
+ for _, job := range jobs {
+ slog.Warn("Found dangling job, moving back to pending", "job", job.ID)
+ err := jm.store.RestartJob(job.ID, job.Output)
+ if err != nil {
+ panic(err)
+ }
+ }
+
ticker := time.NewTicker(2 * time.Second)
go func() {
for {
@@ -46,8 +60,13 @@ func (jm *JobManager) processPendingJobs() {
slog.Error("Worker: Failed to list jobs", "error", err)
return
}
+ activeJobs, err := jm.store.ListJobsByState(store.StateRunning)
+ if err != nil {
+ slog.Error("Worker: Failed to list jobs", "error", err)
+ return
+ }
- if len(jobs) >= conf.MaxJobCount {
+ if len(activeJobs) >= conf.MaxJobCount {
return
}
@@ -57,7 +76,7 @@ func (jm *JobManager) processPendingJobs() {
jm.store.FailJob(job.ID)
continue
}
- slog.Info("Worker: Starting job", "id", job.ID, "cmd", job.Command, "attempt", job.Attempt)
+ slog.Info("Worker: Starting job", "id", job.ID, "cmd", job.Command, "attempt", job.Attempts)
if err := jm.store.AttemptJob(job.ID); err != nil {
slog.Error("Worker: Failed to claim job", "id", job.ID, "error", err)
continue
diff --git a/qj.1.scd b/qj.1.scd
@@ -48,9 +48,9 @@ access to the system.
It is recommended to that the admin updates the users and group to apply
principle of least access. Importantly, the system is intended for only
trusted scripts: the job user has access to the state, and is thus able to
-rewrite access rights. However, users is recommended to use _namespaces(7)_
-or _Landlock(7)_ to limit access rights of the running script so that the
-state can not be rewritten. More security features are coming in the future.
+rewrite access rights. Therefore, it is recommended for the running script to
+use _namespaces(7)_ or _Landlock(7)_ to limit its own access. More security
+features are coming in the future.
Access rights can be modified using _CHOWN(1)_ and _CHMOD(1)_.