Skip to content

Commit dc41280

Browse files
committed
fixes go releaser syscall related errors during packaging
1 parent c936a19 commit dc41280

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

internal/queue/queue.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"log"
77
"os/exec"
88
"sync"
9-
"syscall"
109
"time"
1110

1211
"scriberr/internal/database"
@@ -211,16 +210,12 @@ func (tq *TaskQueue) KillJob(jobID string) error {
211210

212211
log.Printf("Aggressively killing job %s", jobID)
213212

214-
// First, try to kill the OS process immediately with SIGKILL
213+
// First, try to kill the OS process group (or process on non-Unix)
215214
if runningJob.Process != nil && runningJob.Process.Process != nil {
216-
log.Printf("Sending SIGKILL to process %d for job %s", runningJob.Process.Process.Pid, jobID)
217-
218-
// Kill the entire process group to ensure all child processes are terminated
219-
err := syscall.Kill(-runningJob.Process.Process.Pid, syscall.SIGKILL)
220-
if err != nil {
221-
log.Printf("Failed to kill process group for job %s: %v, trying individual process", jobID, err)
222-
// Fallback to killing just the main process
223-
runningJob.Process.Process.Kill()
215+
log.Printf("Attempting to terminate process tree for PID %d (job %s)", runningJob.Process.Process.Pid, jobID)
216+
if err := killProcessTree(runningJob.Process.Process); err != nil {
217+
log.Printf("Failed to terminate process tree for job %s: %v, trying direct kill()", jobID, err)
218+
_ = runningJob.Process.Process.Kill()
224219
}
225220
}
226221

@@ -287,4 +282,4 @@ func (tq *TaskQueue) GetQueueStats() map[string]interface{} {
287282
"completed_jobs": completedCount,
288283
"failed_jobs": failedCount,
289284
}
290-
}
285+
}

internal/transcription/quick_transcription.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"path/filepath"
1010
"strconv"
1111
"sync"
12-
"syscall"
1312
"time"
1413

1514
"scriberr/internal/config"
@@ -203,8 +202,8 @@ func (qs *QuickTranscriptionService) processWithWhisperX(ctx context.Context, jo
203202
cmd := exec.CommandContext(ctx, "uv", args...)
204203
cmd.Env = append(os.Environ(), "PYTHONUNBUFFERED=1")
205204

206-
// Set process group ID so we can kill the entire process tree if needed
207-
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
205+
// Configure process attributes for cross-platform kill behavior
206+
configureCmdSysProcAttr(cmd)
208207

209208
// Execute WhisperX
210209
output, err := cmd.CombinedOutput()

internal/transcription/whisperx.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"path/filepath"
1010
"strconv"
1111
"strings"
12-
"syscall"
1312
"time"
1413

1514
"scriberr/internal/config"
@@ -126,8 +125,8 @@ func (ws *WhisperXService) ProcessJobWithProcess(ctx context.Context, jobID stri
126125
cmd := exec.CommandContext(ctx, "uv", args...)
127126
cmd.Env = append(os.Environ(), "PYTHONUNBUFFERED=1")
128127

129-
// Set process group ID so we can kill the entire process tree
130-
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
128+
// Configure process attributes for cross-platform kill behavior
129+
configureCmdSysProcAttr(cmd)
131130

132131
// Register the process for immediate termination capability
133132
registerProcess(cmd)

0 commit comments

Comments
 (0)