feat(service): add IPC communication and service management

Implement proper CLI-to-service communication via Unix domain sockets,
fixing issue where CLI commands couldn't see jobs managed by the service.

Key changes:
- Add IPC client/server for CLI-service communication
- Fix directory mismatch (CLI used java.io.tmpdir, service used /tmp/barn)
- Add service management commands (start, stop, restart, reload, logs)
- Add service installation for macOS (launchd), Linux (systemd), Windows
- Add process usage monitoring (barn usage command)
- Add job state breakdown in service status (succeeded, failed, canceled)
- Add output formatters (human, JSON, XML)
- Add crash recovery and heartbeat checking
- Add structured logging with MDC context

The CLI commands now properly communicate with the running service
via IPC, ensuring consistent job state visibility.

Fixes #24

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Daniel SamsonandClaude Opus 4.5 committed 2026-01-21 21:41:02 +00:00
1 parent 818c45de0a
commit 92810cabee
103 files changed
+17457 -101

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
<configuration>
<!-- Console appender for development/foreground -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- File appender for daemon mode -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${BARN_LOG_DIR:-${java.io.tmpdir}/barn/logs}/barn.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${BARN_LOG_DIR:-${java.io.tmpdir}/barn/logs}/barn.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<maxHistory>7</maxHistory>
<totalSizeCap>100MB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- JSON appender for structured logging -->
<appender name="JSON" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${BARN_LOG_DIR:-${java.io.tmpdir}/barn/logs}/barn.json.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${BARN_LOG_DIR:-${java.io.tmpdir}/barn/logs}/barn.json.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<maxHistory>7</maxHistory>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeMdcKeyName>jobId</includeMdcKeyName>
<includeMdcKeyName>jobTag</includeMdcKeyName>
</encoder>
</appender>
<root level="${BARN_LOG_LEVEL:-INFO}">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
</configuration>