CLI commands don't use IPC to communicate with running service #24

Closed
opened 2026-10-04 19:28:30 +00:00 by daniel · 2 comments
Owner

Imported from GitHub samson-media/barn#24 — opened by @daniel-samson on 2026-01-21 20:56:08 UTC

Bug Description

CLI commands like barn status, barn run, barn describe, etc. have runWithService() methods that are stubs - they just display an error message instead of actually communicating with the running service via IPC.

Expected Behavior

When the service is running, CLI commands should use IpcClient to send requests to the service via the Unix domain socket at /tmp/barn/barn.sock.

Actual Behavior

All runWithService() methods return:

Service not running. Start with: barn service start
Or use --offline to run without the service.

Even when the service IS running and the socket exists.

Affected Commands

  • StatusCommand.runWithService()
  • RunCommand.runWithService()
  • DescribeCommand.runWithService()
  • KillCommand.runWithService()
  • CleanCommand.runWithService()
  • UsageCommand.runWithService()

Root Cause

The IPC infrastructure (IpcClient, IpcServer, IpcMessage) exists but the CLI commands haven't been wired up to use it.

Fix

Each command's runWithService() method needs to:

  1. Create an IpcClient with the default socket path
  2. Send the appropriate IPC request
  3. Handle the response and display output
<!-- github-import:issue:24 --> _Imported from GitHub samson-media/barn#24 — opened by **@daniel-samson** on 2026-01-21 20:56:08 UTC_ ## Bug Description CLI commands like `barn status`, `barn run`, `barn describe`, etc. have `runWithService()` methods that are stubs - they just display an error message instead of actually communicating with the running service via IPC. ## Expected Behavior When the service is running, CLI commands should use `IpcClient` to send requests to the service via the Unix domain socket at `/tmp/barn/barn.sock`. ## Actual Behavior All `runWithService()` methods return: ``` Service not running. Start with: barn service start Or use --offline to run without the service. ``` Even when the service IS running and the socket exists. ## Affected Commands - `StatusCommand.runWithService()` - `RunCommand.runWithService()` - `DescribeCommand.runWithService()` - `KillCommand.runWithService()` - `CleanCommand.runWithService()` - `UsageCommand.runWithService()` ## Root Cause The IPC infrastructure (`IpcClient`, `IpcServer`, `IpcMessage`) exists but the CLI commands haven't been wired up to use it. ## Fix Each command's `runWithService()` method needs to: 1. Create an `IpcClient` with the default socket path 2. Send the appropriate IPC request 3. Handle the response and display output
daniel added the bug label 2026-10-04 19:28:30 +00:00
Author
Owner

@daniel-samson commented on 2026-01-21 21:07:18 UTC:

Fixed CLI commands to use IPC when communicating with the running service.

Changes:

  1. BarnService.java - Added IPC request handlers:

    • get_status - List jobs with optional filters
    • get_job - Get job details by ID
    • run_job - Create and queue a new job
    • kill_job - Stop a running job
    • clean_jobs - Remove completed jobs
  2. CLI Commands Updated:

    • StatusCommand - Uses IpcClient to fetch job list from service
    • RunCommand - Uses IpcClient to submit jobs to service
    • DescribeCommand - Uses IpcClient to get job details
    • KillCommand - Uses IpcClient to kill jobs via service
    • CleanCommand - Uses IpcClient to clean jobs via service
    • UsageCommand - Uses IpcClient to verify job exists, reads usage.csv directly

All 901 tests pass.

<!-- github-import:comment:3781167406 --> _**@daniel-samson** commented on 2026-01-21 21:07:18 UTC:_ Fixed CLI commands to use IPC when communicating with the running service. **Changes:** 1. **BarnService.java** - Added IPC request handlers: - `get_status` - List jobs with optional filters - `get_job` - Get job details by ID - `run_job` - Create and queue a new job - `kill_job` - Stop a running job - `clean_jobs` - Remove completed jobs 2. **CLI Commands Updated:** - `StatusCommand` - Uses IpcClient to fetch job list from service - `RunCommand` - Uses IpcClient to submit jobs to service - `DescribeCommand` - Uses IpcClient to get job details - `KillCommand` - Uses IpcClient to kill jobs via service - `CleanCommand` - Uses IpcClient to clean jobs via service - `UsageCommand` - Uses IpcClient to verify job exists, reads usage.csv directly All 901 tests pass.
Author
Owner

@daniel-samson commented on 2026-01-21 21:34:21 UTC:

Additional fix applied to resolve remaining issues:

Root Cause:
The CLI commands were using System.getProperty("java.io.tmpdir") for the barn directory on macOS, which returns /var/folders/.../barn. However, the service uses ConfigDefaults.getDefaultBaseDir() which returns /tmp/barn. This directory mismatch meant the CLI commands were looking for jobs in a different directory than where the service was managing them.

Changes:

  1. Updated all CLI commands to use ConfigDefaults.getDefaultBaseDir() consistently
  2. Updated CLI commands to use the socket path from their configured barn directory (via getBarnDirectories().getSocketPath()) instead of a static default
  3. Added getSocketPath() method to BarnDirectories class
  4. Added --barn-dir CLI option to StatusCommand and CleanCommand (hidden, for testing)
  5. Fixed Jackson deserialization issue by configuring ObjectMapper to ignore unknown properties (Job record's boolean accessor methods like isRunning() were being serialized as extra fields)

Testing:

  • All 901 tests pass
  • Manual testing confirms barn status and barn service status now show the same job data
<!-- github-import:comment:3781267782 --> _**@daniel-samson** commented on 2026-01-21 21:34:21 UTC:_ Additional fix applied to resolve remaining issues: **Root Cause:** The CLI commands were using `System.getProperty("java.io.tmpdir")` for the barn directory on macOS, which returns `/var/folders/.../barn`. However, the service uses `ConfigDefaults.getDefaultBaseDir()` which returns `/tmp/barn`. This directory mismatch meant the CLI commands were looking for jobs in a different directory than where the service was managing them. **Changes:** 1. Updated all CLI commands to use `ConfigDefaults.getDefaultBaseDir()` consistently 2. Updated CLI commands to use the socket path from their configured barn directory (via `getBarnDirectories().getSocketPath()`) instead of a static default 3. Added `getSocketPath()` method to `BarnDirectories` class 4. Added `--barn-dir` CLI option to StatusCommand and CleanCommand (hidden, for testing) 5. Fixed Jackson deserialization issue by configuring ObjectMapper to ignore unknown properties (Job record's boolean accessor methods like `isRunning()` were being serialized as extra fields) **Testing:** - All 901 tests pass - Manual testing confirms `barn status` and `barn service status` now show the same job data
This repo is archived. You cannot comment on issues.