Imported from GitHub samson-media/barn#12 — opened by @daniel-samson on 2026-01-21 12:39:29 UTC
Overview
Implement the barn kill command that stops a running job.
Context
Read first: README.md (barn kill examples)
Depends on: #8 (CLI framework), #5 (process execution)
Requirements
1. Kill Command
com.samsonmedia.barn.cli.KillCommand.java:
@Command(name="kill",description="Stop a running job")publicclassKillCommandextendsBaseCommand{@Parameters(index="0",description="Job ID")privateStringjobId;@Option(names={"--force","-f"},description="Force kill (SIGKILL)")privatebooleanforce;@Option(names={"--quiet","-q"},description="No output on success")privatebooleanquiet;@OverridepublicIntegercall(){// 1. Find job by ID// 2. Verify job is running// 3. Send kill signal// 4. Update job state to CANCELED}}
2. Usage Examples
# Kill a job
barn kill job-9f83c
# Force kill (SIGKILL instead of SIGTERM)
barn kill --force job-9f83c
# Quiet mode
barn kill --quiet job-9f83c
# JSON output
barn kill --output=json job-9f83c
3. Kill Behavior
First attempt: SIGTERM (graceful)
Wait briefly for process to exit
If --force or process doesn't exit: SIGKILL
publicvoidkillJob(Jobjob,booleanforce){if(force){ProcessUtils.killTree(job.pid());// SIGKILL}else{ProcessUtils.terminate(job.pid());// SIGTERMif(!waitForExit(job.pid(),gracePeriod)){ProcessUtils.killTree(job.pid());}}repository.complete(job.id(),-1,"Killed by user");repository.updateState(job.id(),JobState.CANCELED);}
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Imported from GitHub samson-media/barn#12 — opened by @daniel-samson on 2026-01-21 12:39:29 UTC
Overview
Implement the
barn killcommand that stops a running job.Context
README.md(barn kill examples)Requirements
1. Kill Command
com.samsonmedia.barn.cli.KillCommand.java:2. Usage Examples
3. Kill Behavior
--forceor process doesn't exit: SIGKILL4. Output
Human format:
JSON format:
5. Error Handling
6. Tests Required
KillCommandTest.java: Test command parsing, error casesAcceptance Criteria
barn kill <id>stops a running job--forceuses SIGKILLmvn verifypassesImplementation Notes
Cross-platform kill:
On Windows,
destroy()is equivalent todestroyForcibly().Definition of Done
@daniel-samson commented on 2026-01-21 14:29:17 UTC:
Implemented barn kill command with tests