Archived
Compare commits
No files matched your search
@@ -46,29 +46,6 @@ jobs:
|
|||||||
name: spotbugs-report
|
name: spotbugs-report
|
||||||
path: target/spotbugsXml.xml
|
path: target/spotbugsXml.xml
|
||||||
|
|
||||||
pmd:
|
|
||||||
name: PMD
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up JDK 21
|
|
||||||
uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
java-version: '21'
|
|
||||||
distribution: 'temurin'
|
|
||||||
cache: maven
|
|
||||||
|
|
||||||
- name: Run PMD
|
|
||||||
run: mvn compile pmd:check
|
|
||||||
|
|
||||||
- name: Upload PMD Report
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
if: failure()
|
|
||||||
with:
|
|
||||||
name: pmd-report
|
|
||||||
path: target/pmd.xml
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Tests
|
name: Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -91,12 +68,9 @@ jobs:
|
|||||||
name: coverage-report
|
name: coverage-report
|
||||||
path: target/site/jacoco/
|
path: target/site/jacoco/
|
||||||
|
|
||||||
- name: Check Coverage Thresholds
|
|
||||||
run: mvn jacoco:check
|
|
||||||
|
|
||||||
verify:
|
verify:
|
||||||
name: Full Verification
|
name: Full Verification
|
||||||
needs: [checkstyle, spotbugs, pmd, test]
|
needs: [checkstyle, spotbugs, test]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ jobs:
|
|||||||
artifact: barn-linux-arm64
|
artifact: barn-linux-arm64
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
artifact: barn-macos-arm64
|
artifact: barn-macos-arm64
|
||||||
|
- os: macos-15-intel
|
||||||
|
artifact: barn-macos-x64
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
artifact: barn-windows-x64
|
artifact: barn-windows-x64
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,17 @@ jobs:
|
|||||||
|
|
||||||
# Get checksums from release
|
# Get checksums from release
|
||||||
curl -sL "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/SHA256SUMS" -o SHA256SUMS
|
curl -sL "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/SHA256SUMS" -o SHA256SUMS
|
||||||
|
cat SHA256SUMS
|
||||||
|
|
||||||
MACOS_ARM64_SHA=$(grep barn-macos-arm64 SHA256SUMS | awk '{print $1}')
|
MACOS_ARM64_SHA=$(grep barn-macos-arm64 SHA256SUMS | awk '{print $1}')
|
||||||
MACOS_X64_SHA=$(grep barn-macos-x64 SHA256SUMS | awk '{print $1}')
|
MACOS_X64_SHA=$(grep barn-macos-x64 SHA256SUMS | awk '{print $1}')
|
||||||
|
LINUX_ARM64_SHA=$(grep barn-linux-arm64 SHA256SUMS | awk '{print $1}')
|
||||||
|
LINUX_X64_SHA=$(grep barn-linux-x64 SHA256SUMS | awk '{print $1}')
|
||||||
|
|
||||||
echo "macos_arm64_sha=$MACOS_ARM64_SHA" >> $GITHUB_OUTPUT
|
echo "macos_arm64_sha=$MACOS_ARM64_SHA" >> $GITHUB_OUTPUT
|
||||||
echo "macos_x64_sha=$MACOS_X64_SHA" >> $GITHUB_OUTPUT
|
echo "macos_x64_sha=$MACOS_X64_SHA" >> $GITHUB_OUTPUT
|
||||||
|
echo "linux_arm64_sha=$LINUX_ARM64_SHA" >> $GITHUB_OUTPUT
|
||||||
|
echo "linux_x64_sha=$LINUX_X64_SHA" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Checkout homebrew tap
|
- name: Checkout homebrew tap
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -31,18 +36,24 @@ jobs:
|
|||||||
path: homebrew-tap
|
path: homebrew-tap
|
||||||
|
|
||||||
- name: Update formula
|
- name: Update formula
|
||||||
|
env:
|
||||||
|
VERSION: ${{ steps.release.outputs.version }}
|
||||||
|
MACOS_ARM64_SHA: ${{ steps.release.outputs.macos_arm64_sha }}
|
||||||
|
MACOS_X64_SHA: ${{ steps.release.outputs.macos_x64_sha }}
|
||||||
|
LINUX_ARM64_SHA: ${{ steps.release.outputs.linux_arm64_sha }}
|
||||||
|
LINUX_X64_SHA: ${{ steps.release.outputs.linux_x64_sha }}
|
||||||
run: |
|
run: |
|
||||||
cat > homebrew-tap/Formula/barn.rb << 'EOF'
|
cat > homebrew-tap/Formula/barn.rb << EOF
|
||||||
class Barn < Formula
|
class Barn < Formula
|
||||||
desc "Cross-platform job daemon for media processing"
|
desc "Cross-platform job daemon for media processing"
|
||||||
homepage "https://github.com/samson-media/barn"
|
homepage "https://github.com/samson-media/barn"
|
||||||
version "${{ steps.release.outputs.version }}"
|
version "${VERSION}"
|
||||||
license "MIT"
|
license "MIT"
|
||||||
|
|
||||||
on_macos do
|
on_macos do
|
||||||
on_arm do
|
on_arm do
|
||||||
url "https://github.com/samson-media/barn/releases/download/v${{ steps.release.outputs.version }}/barn-macos-arm64"
|
url "https://github.com/samson-media/barn/releases/download/v${VERSION}/barn-macos-arm64"
|
||||||
sha256 "${{ steps.release.outputs.macos_arm64_sha }}"
|
sha256 "${MACOS_ARM64_SHA}"
|
||||||
|
|
||||||
def install
|
def install
|
||||||
bin.install "barn-macos-arm64" => "barn"
|
bin.install "barn-macos-arm64" => "barn"
|
||||||
@@ -50,8 +61,8 @@ jobs:
|
|||||||
end
|
end
|
||||||
|
|
||||||
on_intel do
|
on_intel do
|
||||||
url "https://github.com/samson-media/barn/releases/download/v${{ steps.release.outputs.version }}/barn-macos-x64"
|
url "https://github.com/samson-media/barn/releases/download/v${VERSION}/barn-macos-x64"
|
||||||
sha256 "${{ steps.release.outputs.macos_x64_sha }}"
|
sha256 "${MACOS_X64_SHA}"
|
||||||
|
|
||||||
def install
|
def install
|
||||||
bin.install "barn-macos-x64" => "barn"
|
bin.install "barn-macos-x64" => "barn"
|
||||||
@@ -59,11 +70,24 @@ jobs:
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
service do
|
on_linux do
|
||||||
run [opt_bin/"barn", "service", "run"]
|
on_arm do
|
||||||
keep_alive true
|
url "https://github.com/samson-media/barn/releases/download/v${VERSION}/barn-linux-arm64"
|
||||||
log_path var/"log/barn.log"
|
sha256 "${LINUX_ARM64_SHA}"
|
||||||
error_log_path var/"log/barn.error.log"
|
|
||||||
|
def install
|
||||||
|
bin.install "barn-linux-arm64" => "barn"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
on_intel do
|
||||||
|
url "https://github.com/samson-media/barn/releases/download/v${VERSION}/barn-linux-x64"
|
||||||
|
sha256 "${LINUX_X64_SHA}"
|
||||||
|
|
||||||
|
def install
|
||||||
|
bin.install "barn-linux-x64" => "barn"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test do
|
test do
|
||||||
|
|||||||
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/).
|
and this project adheres to [Semantic Versioning](https://semver.org/).
|
||||||
|
|
||||||
|
## [0.1.4] - 2026-01-22
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Intel Mac (x86_64) support
|
||||||
|
|
||||||
|
## [0.1.3] - 2026-01-22
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Debug logs no longer break JSON/XML CLI output (#30)
|
||||||
|
- Replace SLF4J/logback with custom BarnLogger (disabled for CLI, enabled for service)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Update documentation: remove .deb and AUR references (no longer applicable)
|
||||||
|
- Update documentation: add Windows setup.exe installation instructions
|
||||||
|
- Update documentation: clarify auto-update only works with Homebrew
|
||||||
|
|
||||||
## [0.1.2] - 2026-01-21
|
## [0.1.2] - 2026-01-21
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@@ -32,6 +48,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
|||||||
- Jobs that fail to start now properly transition to FAILED state
|
- Jobs that fail to start now properly transition to FAILED state
|
||||||
- Startup errors are written to stderr.log for visibility
|
- Startup errors are written to stderr.log for visibility
|
||||||
|
|
||||||
|
[0.1.4]: https://github.com/samson-media/barn/releases/tag/v0.1.4
|
||||||
|
[0.1.3]: https://github.com/samson-media/barn/releases/tag/v0.1.3
|
||||||
[0.1.2]: https://github.com/samson-media/barn/releases/tag/v0.1.2
|
[0.1.2]: https://github.com/samson-media/barn/releases/tag/v0.1.2
|
||||||
[0.1.1]: https://github.com/samson-media/barn/releases/tag/v0.1.1
|
[0.1.1]: https://github.com/samson-media/barn/releases/tag/v0.1.1
|
||||||
[0.1.0]: https://github.com/samson-media/barn/releases/tag/v0.1.0
|
[0.1.0]: https://github.com/samson-media/barn/releases/tag/v0.1.0
|
||||||
@@ -44,33 +44,40 @@ This project treats FFmpeg jobs as **first-class managed units of work**, not sh
|
|||||||
|
|
||||||
### Quick Install (Recommended)
|
### Quick Install (Recommended)
|
||||||
|
|
||||||
The installer scripts download the latest release, install the binary, and set up barn to run as a service on startup.
|
#### MacOS - Homebrew
|
||||||
|
|
||||||
**macOS / Linux:**
|
|
||||||
```bash
|
|
||||||
curl -fsSL https://raw.githubusercontent.com/samson-media/barn/main/install.sh | sh
|
|
||||||
```
|
|
||||||
|
|
||||||
**Windows (PowerShell as Administrator):**
|
|
||||||
```powershell
|
|
||||||
iwr -useb https://raw.githubusercontent.com/samson-media/barn/main/install.ps1 | iex
|
|
||||||
```
|
|
||||||
|
|
||||||
**Windows Installer (setup.exe):**
|
|
||||||
|
|
||||||
Download the latest `setup-barn-vX.X.X-windows-x64.exe` from the [releases page](https://github.com/samson-media/barn/releases/latest).
|
|
||||||
|
|
||||||
### Alternative Installation Methods
|
|
||||||
|
|
||||||
#### macOS - Homebrew
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew install samson-media/tap/barn
|
brew install samson-media/tap/barn
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Manual Download
|
|
||||||
|
|
||||||
**macOS (ARM64):**
|
#### Linux / MacOS
|
||||||
|
|
||||||
|
The installer scripts download the latest release, install the binary, and set up barn to run as a service on startup.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/samson-media/barn/main/install.sh | sh
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Windows Installer (setup.exe)
|
||||||
|
|
||||||
|
Download the latest `setup-barn-vX.X.X-windows-x64.exe` from the [releases page](https://github.com/samson-media/barn/releases/latest).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Alternative Installation Methods
|
||||||
|
|
||||||
|
### Windows (PowerShell as Administrator)
|
||||||
|
|
||||||
|
The installer scripts download the latest release, install the binary, and set up barn to run as a service on startup.
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
iwr -useb https://raw.githubusercontent.com/samson-media/barn/main/install.ps1 | iex
|
||||||
|
```
|
||||||
|
|
||||||
|
### Manual Download
|
||||||
|
|
||||||
|
**MacOS (ARM64):**
|
||||||
```bash
|
```bash
|
||||||
curl -L -o barn https://github.com/samson-media/barn/releases/latest/download/barn-macos-arm64
|
curl -L -o barn https://github.com/samson-media/barn/releases/latest/download/barn-macos-arm64
|
||||||
chmod +x barn
|
chmod +x barn
|
||||||
@@ -147,19 +154,40 @@ barn is just one binary for both the service and the client. the client uses IPC
|
|||||||
|
|
||||||
clients typically access barn over ssh:
|
clients typically access barn over ssh:
|
||||||
- fetch from webdav server: `barn run --output=json curl -u username:password -o /tmp/barn/input/video.mp4 https://example.com/dav/remote-file.ext`
|
- fetch from webdav server: `barn run --output=json curl -u username:password -o /tmp/barn/input/video.mp4 https://example.com/dav/remote-file.ext`
|
||||||
- analyse file with ffmpeg: `barn run --output=json curl ffprobe -i /tmp/barn/input/video.mp4`
|
- analyse file with ffmpeg: `barn run --output=json ffprobe -i /tmp/barn/input/video.mp4`
|
||||||
- get status of the jobs `bar status --output=json`
|
- get status of the jobs `barn status --output=json`
|
||||||
|
|
||||||
barn's output defaults to a human-readable format, but also supports xml or json via the --output={json|xml} cli option.
|
barn's output defaults to a human-readable format, but also supports xml or json via the --output={json|xml} cli option.
|
||||||
|
|
||||||
### Managing the service
|
### Managing the service
|
||||||
|
|
||||||
There needs to be a barn service in order to run jobs (unless you use --offline). You manage the service using the `barn service` sub command.
|
There needs to be a barn service in order to run jobs (unless you use --offline). You manage the service using the `barn service` sub command.
|
||||||
- `barn service status"` - check the status of the service. up/down, process id etc.
|
- `barn service status` - check the status of the service. up/down, process id etc.
|
||||||
- `barn service start"` - starts barn service process
|
- `barn service start` - starts barn service process
|
||||||
- `barn service stop"` - stops/kills the barn service
|
- `barn service stop` - stops/kills the barn service
|
||||||
- `barn service restart"` - restarts the barn service
|
- `barn service restart` - restarts the barn service
|
||||||
- `barn service reload"` - reloads the configuration and soft restarts the barn service
|
- `barn service reload` - reloads the configuration and soft restarts the barn service
|
||||||
|
|
||||||
|
**Example: `barn service status --output=json`**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"status" : "running",
|
||||||
|
"running" : true,
|
||||||
|
"pid" : 17474,
|
||||||
|
"uptime_seconds" : 16,
|
||||||
|
"started_at" : "2026-01-22T01:48:41.869Z",
|
||||||
|
"jobs" : {
|
||||||
|
"running" : 0,
|
||||||
|
"queued" : 1,
|
||||||
|
"succeeded" : 1,
|
||||||
|
"failed" : 0,
|
||||||
|
"canceled" : 0,
|
||||||
|
"killed" : 0,
|
||||||
|
"total" : 2
|
||||||
|
},
|
||||||
|
"data_dir" : "/tmp/barn"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Adding jobs
|
### Adding jobs
|
||||||
|
|
||||||
@@ -182,19 +210,92 @@ Users can tag job for the purpose of filtering using the --tag=string CLI option
|
|||||||
|
|
||||||
Developers can use the --offline command line option to test how the service behaves eg creating tmp files etc. This runs the same code as the service but without having to run the service
|
Developers can use the --offline command line option to test how the service behaves eg creating tmp files etc. This runs the same code as the service but without having to run the service
|
||||||
|
|
||||||
> barn's output defaults to a human-readable format, but also supports xml or json via the --output={json|xml} cli option.
|
**Example: `barn run --output=json -- echo "Hello World"`**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id" : "job-6d368040",
|
||||||
|
"state" : "QUEUED",
|
||||||
|
"command" : [ "echo", "Hello World" ],
|
||||||
|
"tag" : null,
|
||||||
|
"createdAt" : "2026-01-22T01:48:46.749629Z",
|
||||||
|
"startedAt" : null,
|
||||||
|
"finishedAt" : null,
|
||||||
|
"exitCode" : null,
|
||||||
|
"error" : null,
|
||||||
|
"pid" : null,
|
||||||
|
"heartbeat" : null,
|
||||||
|
"retryCount" : 0,
|
||||||
|
"retryAt" : null,
|
||||||
|
"terminal" : false,
|
||||||
|
"running" : false,
|
||||||
|
"queued" : true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Get status of jobs
|
### Get status of jobs
|
||||||
|
|
||||||
`bar status` gets the status of all jobs found in /tmp.
|
`barn status` gets the status of all jobs found in /tmp.
|
||||||
|
|
||||||
> barn's output defaults to a human-readable format, but also supports xml or json via the --output={json|xml} cli option.
|
**Example: `barn status --output=json`**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"jobs" : [ {
|
||||||
|
"id" : "job-6d368040",
|
||||||
|
"state" : "SUCCEEDED",
|
||||||
|
"command" : [ "echo", "Hello World" ],
|
||||||
|
"tag" : null,
|
||||||
|
"createdAt" : "2026-01-22T01:48:46.739979Z",
|
||||||
|
"startedAt" : "2026-01-22T01:48:47.161895Z",
|
||||||
|
"finishedAt" : "2026-01-22T01:48:47.184605Z",
|
||||||
|
"exitCode" : 0,
|
||||||
|
"error" : null,
|
||||||
|
"pid" : 17486,
|
||||||
|
"heartbeat" : "2026-01-22T01:48:47.161895Z",
|
||||||
|
"retryCount" : 0,
|
||||||
|
"retryAt" : null,
|
||||||
|
"running" : false,
|
||||||
|
"terminal" : true,
|
||||||
|
"queued" : false
|
||||||
|
} ],
|
||||||
|
"summary" : {
|
||||||
|
"total" : 1,
|
||||||
|
"queued" : 0,
|
||||||
|
"running" : 0,
|
||||||
|
"succeeded" : 1,
|
||||||
|
"failed" : 0,
|
||||||
|
"canceled" : 0,
|
||||||
|
"killed" : 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Get Details of a job
|
### Get Details of a job
|
||||||
`barn describe {jobId}` - collects all the info from /tmp and display it
|
`barn describe {jobId}` - collects all the info from /tmp and display it
|
||||||
|
|
||||||
> barn's output defaults to a human-readable format, but also supports xml or json via the --output={json|xml} cli option.
|
**Example: `barn describe job-6d368040 --output=json`**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id" : "job-6d368040",
|
||||||
|
"state" : "succeeded",
|
||||||
|
"tag" : null,
|
||||||
|
"command" : [ "echo", "Hello World" ],
|
||||||
|
"createdAt" : "2026-01-22T01:48:46.739979Z",
|
||||||
|
"startedAt" : "2026-01-22T01:48:47.161895Z",
|
||||||
|
"finishedAt" : "2026-01-22T01:48:47.184605Z",
|
||||||
|
"pid" : 17486,
|
||||||
|
"exitCode" : 0,
|
||||||
|
"error" : null,
|
||||||
|
"heartbeat" : "2026-01-22T01:48:47.161895Z",
|
||||||
|
"retryCount" : 0,
|
||||||
|
"retryAt" : null,
|
||||||
|
"paths" : {
|
||||||
|
"jobDir" : "/tmp/barn/jobs/job-6d368040",
|
||||||
|
"workDir" : "/tmp/barn/jobs/job-6d368040/work",
|
||||||
|
"logsDir" : "/tmp/barn/jobs/job-6d368040/logs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -202,19 +303,8 @@ Developers can use the --offline command line option to test how the service beh
|
|||||||
### Stop a job
|
### Stop a job
|
||||||
`barn kill {jobId}` - kills a job process
|
`barn kill {jobId}` - kills a job process
|
||||||
|
|
||||||
> barn's output defaults to a human-readable format, but also supports xml or json via the --output={json|xml} cli option.
|
|
||||||
|
|
||||||
|
|
||||||
### Stop a job
|
|
||||||
`barn kill {jobId}` - kills a job
|
|
||||||
|
|
||||||
> barn's output defaults to a human-readable format, but also supports xml or json via the --output={json|xml} cli option.
|
|
||||||
|
|
||||||
|
|
||||||
### Clean up jobs
|
### Clean up jobs
|
||||||
`barn clean` - removes completed jobs and cleans up old jobs (older than max_age config) with errors from /tmp
|
`barn clean` - removes completed jobs and cleans up old jobs (older than max_age config) from /tmp
|
||||||
|
|
||||||
> barn's output defaults to a human-readable format, but also supports xml or json via the --output={json|xml} cli option.
|
|
||||||
|
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
@@ -225,7 +315,7 @@ Developers can use the --offline command line option to test how the service beh
|
|||||||
- [Coding Standards](docs/coding-standards.md) defines code style, conventions, and quality enforcement
|
- [Coding Standards](docs/coding-standards.md) defines code style, conventions, and quality enforcement
|
||||||
- [Releasing](docs/releasing.md) describes version management and the release process
|
- [Releasing](docs/releasing.md) describes version management and the release process
|
||||||
- [CI/CD](docs/ci-cd.md) documents the GitHub Actions workflows for building and releasing
|
- [CI/CD](docs/ci-cd.md) documents the GitHub Actions workflows for building and releasing
|
||||||
- [Distribution](docs/distribution.md) covers package manager setup (WinGet, apt, AUR, Homebrew)
|
- [Distribution](docs/distribution.md) covers installation methods (Windows setup, Linux binary, Homebrew)
|
||||||
- [Auto-Update](docs/auto-update.md) explains the built-in `barn update` command
|
- [Updating](docs/auto-update.md) explains how to update Barn on each platform
|
||||||
- [Automated Testing](docs/testing-automated.md) covers the test suite, running tests, and CI integration
|
- [Automated Testing](docs/testing-automated.md) covers the test suite, running tests, and CI integration
|
||||||
- [Manual Testing](docs/testing-manual.md) provides step-by-step manual test procedures
|
- [Manual Testing](docs/testing-manual.md) provides step-by-step manual test procedures
|
||||||
@@ -1,160 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<ruleset name="Barn PMD Ruleset"
|
|
||||||
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
|
||||||
|
|
||||||
<description>
|
|
||||||
PMD ruleset for Barn project.
|
|
||||||
Based on PMD best practices with adjustments for modern Java.
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
<!-- BEST PRACTICES -->
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
|
|
||||||
<rule ref="category/java/bestpractices.xml">
|
|
||||||
<!-- Allow JUnit 5 assertions -->
|
|
||||||
<exclude name="JUnitTestContainsTooManyAsserts"/>
|
|
||||||
<exclude name="JUnitAssertionsShouldIncludeMessage"/>
|
|
||||||
<!-- We use Mockito, not JUnit 4 -->
|
|
||||||
<exclude name="JUnit4TestShouldUseTestAnnotation"/>
|
|
||||||
<exclude name="JUnit4TestShouldUseBeforeAnnotation"/>
|
|
||||||
<exclude name="JUnit4TestShouldUseAfterAnnotation"/>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod">
|
|
||||||
<properties>
|
|
||||||
<property name="ignoredAnnotations" value="jakarta.annotation.PostConstruct|javax.annotation.PostConstruct"/>
|
|
||||||
</properties>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
<!-- CODE STYLE -->
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
|
|
||||||
<rule ref="category/java/codestyle.xml">
|
|
||||||
<!-- We prefer explicit imports -->
|
|
||||||
<exclude name="OnlyOneReturn"/>
|
|
||||||
<!-- Allow short variable names like 'id', 'in', 'out' -->
|
|
||||||
<exclude name="ShortVariable"/>
|
|
||||||
<!-- Allow longer method names for clarity -->
|
|
||||||
<exclude name="LongVariable"/>
|
|
||||||
<!-- Allow static imports for test utilities -->
|
|
||||||
<exclude name="TooManyStaticImports"/>
|
|
||||||
<!-- We have our own formatting rules -->
|
|
||||||
<exclude name="AtLeastOneConstructor"/>
|
|
||||||
<!-- Allow default package for CLI commands -->
|
|
||||||
<exclude name="CommentDefaultAccessModifier"/>
|
|
||||||
<!-- Java 21+ has useful implicit classes -->
|
|
||||||
<exclude name="UnnecessaryFullyQualifiedName"/>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule ref="category/java/codestyle.xml/ClassNamingConventions">
|
|
||||||
<properties>
|
|
||||||
<property name="utilityClassPattern" value="[A-Z][a-zA-Z0-9]+(Utils?|Helper|Constants)"/>
|
|
||||||
</properties>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule ref="category/java/codestyle.xml/MethodNamingConventions">
|
|
||||||
<properties>
|
|
||||||
<property name="methodPattern" value="[a-z][a-zA-Z0-9]*"/>
|
|
||||||
<property name="nativePattern" value="[a-z][a-zA-Z0-9]*"/>
|
|
||||||
</properties>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
<!-- DESIGN -->
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
|
|
||||||
<rule ref="category/java/design.xml">
|
|
||||||
<!-- Modern Java allows reasonable complexity -->
|
|
||||||
<exclude name="LawOfDemeter"/>
|
|
||||||
<!-- Allow data classes with many fields -->
|
|
||||||
<exclude name="TooManyFields"/>
|
|
||||||
<!-- Exclude for builders and configs -->
|
|
||||||
<exclude name="ExcessivePublicCount"/>
|
|
||||||
<!-- Allow reasonable method size -->
|
|
||||||
<exclude name="ExcessiveMethodLength"/>
|
|
||||||
<!-- Allow reasonable class size -->
|
|
||||||
<exclude name="ExcessiveClassLength"/>
|
|
||||||
<!-- Too strict for modern patterns -->
|
|
||||||
<exclude name="AvoidCatchingGenericException"/>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule ref="category/java/design.xml/CyclomaticComplexity">
|
|
||||||
<properties>
|
|
||||||
<property name="classReportLevel" value="80"/>
|
|
||||||
<property name="methodReportLevel" value="15"/>
|
|
||||||
</properties>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule ref="category/java/design.xml/NPathComplexity">
|
|
||||||
<properties>
|
|
||||||
<property name="reportLevel" value="200"/>
|
|
||||||
</properties>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule ref="category/java/design.xml/TooManyMethods">
|
|
||||||
<properties>
|
|
||||||
<property name="maxmethods" value="25"/>
|
|
||||||
</properties>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
<!-- DOCUMENTATION -->
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
|
|
||||||
<rule ref="category/java/documentation.xml">
|
|
||||||
<exclude name="CommentRequired"/>
|
|
||||||
<exclude name="CommentSize"/>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
<!-- ERROR PRONE -->
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
|
|
||||||
<rule ref="category/java/errorprone.xml">
|
|
||||||
<!-- Allow null assignments in cleanup -->
|
|
||||||
<exclude name="NullAssignment"/>
|
|
||||||
<!-- Allow close in finally for legacy code -->
|
|
||||||
<exclude name="CloseResource"/>
|
|
||||||
<!-- We validate beans differently -->
|
|
||||||
<exclude name="BeanMembersShouldSerialize"/>
|
|
||||||
<!-- Too strict -->
|
|
||||||
<exclude name="DataflowAnomalyAnalysis"/>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule ref="category/java/errorprone.xml/AvoidLiteralsInIfCondition">
|
|
||||||
<properties>
|
|
||||||
<property name="ignoreMagicNumbers" value="-1,0,1,2"/>
|
|
||||||
<property name="ignoreExpressions" value="true"/>
|
|
||||||
</properties>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
<!-- MULTITHREADING -->
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
|
|
||||||
<rule ref="category/java/multithreading.xml">
|
|
||||||
<!-- We use modern concurrency utilities -->
|
|
||||||
<exclude name="UseConcurrentHashMap"/>
|
|
||||||
<exclude name="DoNotUseThreads"/>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
<!-- PERFORMANCE -->
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
|
|
||||||
<rule ref="category/java/performance.xml">
|
|
||||||
<!-- Modern JVM handles this well -->
|
|
||||||
<exclude name="AvoidInstantiatingObjectsInLoops"/>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
<!-- SECURITY -->
|
|
||||||
<!-- ================================================================== -->
|
|
||||||
|
|
||||||
<rule ref="category/java/security.xml"/>
|
|
||||||
|
|
||||||
</ruleset>
|
|
||||||
+146
-1
@@ -24,15 +24,29 @@
|
|||||||
<Bug pattern="DM_EXIT"/>
|
<Bug pattern="DM_EXIT"/>
|
||||||
</Match>
|
</Match>
|
||||||
|
|
||||||
<!-- Allow command execution in specific classes -->
|
<!-- Allow command execution in specific classes - commands are hardcoded, not user input -->
|
||||||
<Match>
|
<Match>
|
||||||
<Or>
|
<Or>
|
||||||
<Class name="~.*ProcessExecutor.*"/>
|
<Class name="~.*ProcessExecutor.*"/>
|
||||||
<Class name="~.*CommandRunner.*"/>
|
<Class name="~.*CommandRunner.*"/>
|
||||||
|
<Class name="~.*ServiceStartCommand.*"/>
|
||||||
|
<Class name="~.*ServiceStopCommand.*"/>
|
||||||
|
<Class name="~.*ServiceRestartCommand.*"/>
|
||||||
|
<Class name="~.*ServiceInstallCommand.*"/>
|
||||||
|
<Class name="~.*ServiceUninstallCommand.*"/>
|
||||||
|
<Class name="~.*WindowsServiceManager.*"/>
|
||||||
|
<Class name="~.*SystemdManager.*"/>
|
||||||
|
<Class name="~.*LaunchdManager.*"/>
|
||||||
|
<Class name="~.*UsageCollector.*"/>
|
||||||
</Or>
|
</Or>
|
||||||
<Bug pattern="COMMAND_INJECTION"/>
|
<Bug pattern="COMMAND_INJECTION"/>
|
||||||
</Match>
|
</Match>
|
||||||
|
|
||||||
|
<!-- CRLF injection in logs is not exploitable - we log internal identifiers like job IDs -->
|
||||||
|
<Match>
|
||||||
|
<Bug pattern="CRLF_INJECTION_LOGS"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
<!-- Exclude false positives for try-with-resources -->
|
<!-- Exclude false positives for try-with-resources -->
|
||||||
<Match>
|
<Match>
|
||||||
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
|
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
|
||||||
@@ -46,4 +60,135 @@
|
|||||||
</Not>
|
</Not>
|
||||||
</Match>
|
</Match>
|
||||||
|
|
||||||
|
<!-- Hardcoded absolute paths are intentional for system service installation paths -->
|
||||||
|
<Match>
|
||||||
|
<Or>
|
||||||
|
<Class name="~.*ConfigDefaults.*"/>
|
||||||
|
<Class name="~.*ServiceInstallCommand.*"/>
|
||||||
|
<Class name="~.*SystemdManager.*"/>
|
||||||
|
<Class name="~.*LaunchdManager.*"/>
|
||||||
|
<Class name="~.*IpcClient.*"/>
|
||||||
|
</Or>
|
||||||
|
<Bug pattern="DMI_HARDCODED_ABSOLUTE_FILENAME"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- XmlFormatter uses internal data, not user input - XML injection not applicable -->
|
||||||
|
<Match>
|
||||||
|
<Class name="~.*XmlFormatter.*"/>
|
||||||
|
<Bug pattern="POTENTIAL_XML_INJECTION"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- Throwing exceptions from constructors is a valid pattern for checked initialization -->
|
||||||
|
<Match>
|
||||||
|
<Bug pattern="CT_CONSTRUCTOR_THROW"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- ThreadLocalRandom for retry jitter doesn't need cryptographic randomness -->
|
||||||
|
<Match>
|
||||||
|
<Class name="~.*RetryCalculator.*"/>
|
||||||
|
<Bug pattern="PREDICTABLE_RANDOM"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- Using \n instead of %n is intentional for systemd/launchd config file templates -->
|
||||||
|
<Match>
|
||||||
|
<Or>
|
||||||
|
<Class name="~.*SystemdManager.*"/>
|
||||||
|
<Class name="~.*LaunchdManager.*"/>
|
||||||
|
</Or>
|
||||||
|
<Bug pattern="VA_FORMAT_STRING_USES_NEWLINE"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- Exposing internal representation is acceptable for records and DTOs -->
|
||||||
|
<Match>
|
||||||
|
<Or>
|
||||||
|
<Class name="~.*IpcMessage.*"/>
|
||||||
|
<Class name="~.*IpcRequest.*"/>
|
||||||
|
<Class name="~.*ProcessMonitor.*"/>
|
||||||
|
<Class name="~.*BarnService.*"/>
|
||||||
|
</Or>
|
||||||
|
<Or>
|
||||||
|
<Bug pattern="EI_EXPOSE_REP"/>
|
||||||
|
<Bug pattern="EI_EXPOSE_REP2"/>
|
||||||
|
</Or>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- Lazy initialization race condition in OperatingSystem.current() is benign -->
|
||||||
|
<Match>
|
||||||
|
<Class name="~.*OperatingSystem.*"/>
|
||||||
|
<Bug pattern="LI_LAZY_INIT_STATIC"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- Catching generic Exception is intentional in some cases for resilience -->
|
||||||
|
<Match>
|
||||||
|
<Or>
|
||||||
|
<Class name="~.*UsageCollector.*"/>
|
||||||
|
<Class name="~.*XmlFormatter.*"/>
|
||||||
|
</Or>
|
||||||
|
<Bug pattern="REC_CATCH_EXCEPTION"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- Throwing RuntimeException is intentional in ProcessMonitor for fatal errors -->
|
||||||
|
<Match>
|
||||||
|
<Class name="~.*ProcessMonitor.*"/>
|
||||||
|
<Bug pattern="THROWS_METHOD_THROWS_RUNTIMEEXCEPTION"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- Ignored Future returns are intentional for fire-and-forget tasks -->
|
||||||
|
<Match>
|
||||||
|
<Or>
|
||||||
|
<Class name="~.*JobScheduler.*"/>
|
||||||
|
<Class name="~.*IpcServer.*"/>
|
||||||
|
</Or>
|
||||||
|
<Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- Format string manipulation warnings in CLI - internal use only -->
|
||||||
|
<Match>
|
||||||
|
<Class name="~.*StatusCommand.*"/>
|
||||||
|
<Bug pattern="FORMAT_STRING_MANIPULATION"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- Use of TEMP env variable is intentional for Windows compatibility -->
|
||||||
|
<Match>
|
||||||
|
<Class name="~.*ConfigDefaults.*"/>
|
||||||
|
<Bug pattern="ENV_USE_PROPERTY_INSTEAD_OF_ENV"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- toLowerCase with Locale.ROOT is correct - these are false positives -->
|
||||||
|
<Match>
|
||||||
|
<Bug pattern="IMPROPER_UNICODE"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- IpcClient/IpcServer streams wrap channels managed separately - closing streams would close channels -->
|
||||||
|
<Match>
|
||||||
|
<Or>
|
||||||
|
<Class name="~.*IpcClient.*"/>
|
||||||
|
<Class name="~.*IpcServer.*"/>
|
||||||
|
</Or>
|
||||||
|
<Bug pattern="OS_OPEN_STREAM"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- Paths are always absolute in this codebase - getParent()/getFileName() won't return null -->
|
||||||
|
<Match>
|
||||||
|
<Or>
|
||||||
|
<Class name="~.*ProcessExecutor.*"/>
|
||||||
|
<Class name="~.*JobRunner.*"/>
|
||||||
|
<Class name="~.*JobRepository.*"/>
|
||||||
|
<Class name="~.*IpcServer.*"/>
|
||||||
|
</Or>
|
||||||
|
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- BarnLogger.setOutput() intentionally exposes mutable state for testing purposes -->
|
||||||
|
<Match>
|
||||||
|
<Class name="~.*BarnLogger.*"/>
|
||||||
|
<Bug pattern="EI_EXPOSE_STATIC_REP2"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
|
<!-- BarnLogger error logging intentionally prints stack traces - that's its purpose -->
|
||||||
|
<Match>
|
||||||
|
<Class name="~.*BarnLogger.*"/>
|
||||||
|
<Bug pattern="INFORMATION_EXPOSURE_THROUGH_AN_ERROR_MESSAGE"/>
|
||||||
|
</Match>
|
||||||
|
|
||||||
</FindBugsFilter>
|
</FindBugsFilter>
|
||||||
+69
-386
@@ -1,137 +1,100 @@
|
|||||||
# Auto-Update
|
# Updating Barn
|
||||||
|
|
||||||
This document describes Barn's built-in self-update mechanism.
|
This document describes how to keep Barn updated on different platforms.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
Barn includes a `barn update` command that can check for and install new versions directly from GitHub Releases without requiring a package manager.
|
| Platform | Update Method | Automatic |
|
||||||
|
|----------|---------------|-----------|
|
||||||
|
| macOS (Homebrew) | `brew upgrade barn` | Yes |
|
||||||
|
| macOS (manual) | Download from GitHub Releases | No |
|
||||||
|
| Windows | Download setup installer from GitHub Releases | No |
|
||||||
|
| Linux | Download binary from GitHub Releases | No |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Commands
|
## macOS (Homebrew)
|
||||||
|
|
||||||
### Check for Updates
|
If you installed Barn via Homebrew, updates are handled automatically:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
barn update --check
|
# Check for updates
|
||||||
|
brew outdated barn
|
||||||
|
|
||||||
|
# Update Barn
|
||||||
|
brew upgrade barn
|
||||||
|
|
||||||
|
# Restart the service after updating
|
||||||
|
brew services restart barn
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Homebrew will automatically fetch the latest version from the Homebrew tap when you run `brew upgrade`.
|
||||||
|
|
||||||
```
|
---
|
||||||
Current version: 1.2.3
|
|
||||||
Latest version: 1.3.0
|
|
||||||
Update available: yes
|
|
||||||
|
|
||||||
Run 'barn update' to install the latest version.
|
## macOS (Manual Installation)
|
||||||
```
|
|
||||||
|
|
||||||
### Install Latest Version
|
If you installed Barn manually (not via Homebrew):
|
||||||
|
|
||||||
```bash
|
1. Download the latest binary from [GitHub Releases](https://github.com/samson-media/barn/releases/latest)
|
||||||
barn update
|
2. Stop the service: `barn service stop`
|
||||||
```
|
3. Replace the binary:
|
||||||
|
```bash
|
||||||
|
chmod +x barn-macos-arm64
|
||||||
|
sudo mv barn-macos-arm64 /usr/local/bin/barn
|
||||||
|
```
|
||||||
|
4. Verify: `barn --version`
|
||||||
|
5. Start the service: `barn service start`
|
||||||
|
|
||||||
Output:
|
---
|
||||||
|
|
||||||
```
|
## Windows
|
||||||
Current version: 1.2.3
|
|
||||||
Latest version: 1.3.0
|
|
||||||
|
|
||||||
Downloading barn-macos-arm64...
|
To update Barn on Windows:
|
||||||
Verifying checksum...
|
|
||||||
Installing...
|
|
||||||
Restarting service...
|
|
||||||
|
|
||||||
Successfully updated to version 1.3.0
|
1. Download the latest `setup-barn-vX.X.X-windows-x64.exe` from [GitHub Releases](https://github.com/samson-media/barn/releases/latest)
|
||||||
```
|
2. Run the installer - it will automatically:
|
||||||
|
- Stop the Barn service
|
||||||
|
- Update the binary
|
||||||
|
- Restart the service
|
||||||
|
|
||||||
### Install Specific Version
|
Alternatively, for silent updates:
|
||||||
|
|
||||||
```bash
|
```powershell
|
||||||
barn update --version=1.2.0
|
# Download the installer
|
||||||
```
|
Invoke-WebRequest -Uri "https://github.com/samson-media/barn/releases/latest/download/setup-barn-vX.X.X-windows-x64.exe" -OutFile "setup-barn.exe"
|
||||||
|
|
||||||
### Force Update (Reinstall Current Version)
|
# Run silent installation
|
||||||
|
.\setup-barn.exe /S
|
||||||
```bash
|
|
||||||
barn update --force
|
|
||||||
```
|
|
||||||
|
|
||||||
### JSON Output
|
|
||||||
|
|
||||||
```bash
|
|
||||||
barn update --check --output=json
|
|
||||||
```
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"current_version": "1.2.3",
|
|
||||||
"latest_version": "1.3.0",
|
|
||||||
"update_available": true,
|
|
||||||
"release_url": "https://github.com/samson-media/barn/releases/tag/v1.3.0"
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Update Flow
|
## Linux
|
||||||
|
|
||||||
### 1. Query GitHub Releases API
|
To update Barn on Linux:
|
||||||
|
|
||||||
Barn queries the GitHub Releases API to find the latest version:
|
1. Download the latest binary from [GitHub Releases](https://github.com/samson-media/barn/releases/latest)
|
||||||
|
2. Stop the service:
|
||||||
|
```bash
|
||||||
|
sudo systemctl stop barn
|
||||||
|
```
|
||||||
|
3. Replace the binary:
|
||||||
|
```bash
|
||||||
|
chmod +x barn-linux-x64
|
||||||
|
sudo mv barn-linux-x64 /usr/local/bin/barn
|
||||||
|
```
|
||||||
|
4. Verify: `barn --version`
|
||||||
|
5. Start the service:
|
||||||
|
```bash
|
||||||
|
sudo systemctl start barn
|
||||||
|
```
|
||||||
|
|
||||||
```
|
---
|
||||||
GET https://api.github.com/repos/samson-media/barn/releases/latest
|
|
||||||
```
|
|
||||||
|
|
||||||
Response includes:
|
## Checking Your Current Version
|
||||||
- Version tag
|
|
||||||
- Asset download URLs
|
|
||||||
- Checksums
|
|
||||||
|
|
||||||
### 2. Compare Versions
|
|
||||||
|
|
||||||
Versions are compared using semantic versioning:
|
|
||||||
|
|
||||||
```
|
|
||||||
1.3.0 > 1.2.3 → Update available
|
|
||||||
1.2.3 = 1.2.3 → Up to date
|
|
||||||
1.2.0 < 1.2.3 → Downgrade (requires --force)
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. Download Binary
|
|
||||||
|
|
||||||
The appropriate binary is downloaded based on OS and architecture:
|
|
||||||
|
|
||||||
| OS | Architecture | Asset |
|
|
||||||
|----|--------------|-------|
|
|
||||||
| Linux | x86_64 | `barn-linux-x64` |
|
|
||||||
| Linux | ARM64 | `barn-linux-arm64` |
|
|
||||||
| macOS | x86_64 | `barn-macos-x64` |
|
|
||||||
| macOS | ARM64 | `barn-macos-arm64` |
|
|
||||||
| Windows | x86_64 | `barn-windows-x64.exe` |
|
|
||||||
|
|
||||||
### 4. Verify Checksum
|
|
||||||
|
|
||||||
The SHA256 checksum is verified against `SHA256SUMS`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Downloaded automatically and verified
|
|
||||||
sha256sum -c SHA256SUMS
|
|
||||||
```
|
|
||||||
|
|
||||||
If verification fails, the update is aborted.
|
|
||||||
|
|
||||||
### 5. Replace Binary
|
|
||||||
|
|
||||||
The old binary is replaced with the new one.
|
|
||||||
|
|
||||||
### 6. Verify Installation
|
|
||||||
|
|
||||||
After replacement, Barn verifies the new binary works:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
barn --version
|
barn --version
|
||||||
@@ -139,296 +102,16 @@ barn --version
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Platform-Specific Behavior
|
## Release Notifications
|
||||||
|
|
||||||
### Windows
|
To be notified of new releases, watch the [GitHub repository](https://github.com/samson-media/barn):
|
||||||
|
|
||||||
Windows cannot replace a running executable. The update process:
|
1. Go to https://github.com/samson-media/barn
|
||||||
|
2. Click "Watch" → "Custom" → Select "Releases"
|
||||||
1. Download new binary to temp location
|
|
||||||
2. Stop the Barn service
|
|
||||||
3. Rename current `barn.exe` to `barn.exe.old`
|
|
||||||
4. Move new binary to `barn.exe`
|
|
||||||
5. Start the Barn service
|
|
||||||
6. Delete `barn.exe.old` on next run
|
|
||||||
|
|
||||||
```
|
|
||||||
C:\Program Files\Barn\
|
|
||||||
barn.exe ← New version
|
|
||||||
barn.exe.old ← Previous version (deleted on next run)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Linux / macOS
|
|
||||||
|
|
||||||
Direct replacement if permissions allow:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Requires write permission to binary location
|
|
||||||
sudo barn update
|
|
||||||
```
|
|
||||||
|
|
||||||
If running without sudo and binary is in a protected location:
|
|
||||||
|
|
||||||
```
|
|
||||||
Error: Cannot update binary at /usr/local/bin/barn
|
|
||||||
Permission denied. Run with sudo or use your package manager.
|
|
||||||
```
|
|
||||||
|
|
||||||
### Package Manager Installations
|
|
||||||
|
|
||||||
If Barn detects it was installed via a package manager, it warns the user:
|
|
||||||
|
|
||||||
```
|
|
||||||
Warning: Barn appears to be installed via Homebrew.
|
|
||||||
Using 'barn update' may conflict with your package manager.
|
|
||||||
|
|
||||||
Recommended: Run 'brew upgrade barn' instead.
|
|
||||||
|
|
||||||
Continue anyway? [y/N]
|
|
||||||
```
|
|
||||||
|
|
||||||
Detection methods:
|
|
||||||
|
|
||||||
| Package Manager | Detection |
|
|
||||||
|-----------------|-----------|
|
|
||||||
| Homebrew | Binary in `/opt/homebrew/` or `/usr/local/Cellar/` |
|
|
||||||
| apt/dpkg | Binary in `/usr/bin/` with dpkg ownership |
|
|
||||||
| pacman | Binary in `/usr/bin/` with pacman ownership |
|
|
||||||
| WinGet | Registry entries present |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Security
|
|
||||||
|
|
||||||
### HTTPS Only
|
|
||||||
|
|
||||||
All downloads use HTTPS. HTTP is never used.
|
|
||||||
|
|
||||||
### Checksum Verification
|
|
||||||
|
|
||||||
Every download is verified against the published SHA256 checksum:
|
|
||||||
|
|
||||||
```
|
|
||||||
SHA256SUMS content:
|
|
||||||
a1b2c3d4... barn-linux-x64
|
|
||||||
e5f6g7h8... barn-linux-arm64
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
If the checksum doesn't match, the update fails:
|
|
||||||
|
|
||||||
```
|
|
||||||
Error: Checksum verification failed
|
|
||||||
Expected: a1b2c3d4...
|
|
||||||
Got: xxxxxxxx...
|
|
||||||
|
|
||||||
The download may be corrupted or tampered with.
|
|
||||||
Update aborted.
|
|
||||||
```
|
|
||||||
|
|
||||||
### Signature Verification (Optional)
|
|
||||||
|
|
||||||
If GPG signatures are published, Barn can verify them:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
barn update --verify-signature
|
|
||||||
```
|
|
||||||
|
|
||||||
This requires the Samson Media public key to be imported.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
Update behavior can be configured in `barn.conf`:
|
|
||||||
|
|
||||||
```toml
|
|
||||||
[update]
|
|
||||||
# Disable update checks
|
|
||||||
enabled = true
|
|
||||||
|
|
||||||
# Check for updates automatically on service start
|
|
||||||
check_on_start = true
|
|
||||||
|
|
||||||
# Notify about updates without auto-installing
|
|
||||||
auto_install = false
|
|
||||||
|
|
||||||
# GitHub API endpoint (for enterprise GitHub)
|
|
||||||
github_api = "https://api.github.com"
|
|
||||||
|
|
||||||
# Proxy settings
|
|
||||||
proxy = ""
|
|
||||||
```
|
|
||||||
|
|
||||||
### Environment Variables
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Disable update functionality
|
|
||||||
BARN_UPDATE_ENABLED=false
|
|
||||||
|
|
||||||
# Use proxy for downloads
|
|
||||||
BARN_UPDATE_PROXY=http://proxy.example.com:8080
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Rollback
|
|
||||||
|
|
||||||
Barn keeps the previous version as a backup.
|
|
||||||
|
|
||||||
### Automatic Backup
|
|
||||||
|
|
||||||
During update, the previous binary is preserved:
|
|
||||||
|
|
||||||
| Platform | Backup Location |
|
|
||||||
|----------|-----------------|
|
|
||||||
| Linux/macOS | `/usr/local/bin/barn.backup` or alongside binary |
|
|
||||||
| Windows | `barn.exe.backup` |
|
|
||||||
|
|
||||||
### Manual Rollback
|
|
||||||
|
|
||||||
```bash
|
|
||||||
barn update --rollback
|
|
||||||
```
|
|
||||||
|
|
||||||
Or manually:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Linux/macOS
|
|
||||||
sudo mv /usr/local/bin/barn.backup /usr/local/bin/barn
|
|
||||||
|
|
||||||
# Windows
|
|
||||||
move "C:\Program Files\Barn\barn.exe.backup" "C:\Program Files\Barn\barn.exe"
|
|
||||||
```
|
|
||||||
|
|
||||||
### Rollback Retention
|
|
||||||
|
|
||||||
Only the most recent previous version is kept. Older backups are deleted.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Offline Mode
|
|
||||||
|
|
||||||
If network is unavailable:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
barn update --check
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
Error: Cannot reach GitHub API
|
|
||||||
Check your network connection or proxy settings.
|
|
||||||
|
|
||||||
For offline installation, download the binary manually from:
|
|
||||||
https://github.com/samson-media/barn/releases
|
|
||||||
```
|
|
||||||
|
|
||||||
### Manual Offline Update
|
|
||||||
|
|
||||||
1. Download binary on another machine
|
|
||||||
2. Transfer to target machine
|
|
||||||
3. Replace binary manually:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
chmod +x barn-linux-x64
|
|
||||||
sudo mv barn-linux-x64 /usr/local/bin/barn
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Update Notifications
|
|
||||||
|
|
||||||
When `check_on_start = true`, Barn checks for updates when the service starts and logs:
|
|
||||||
|
|
||||||
```
|
|
||||||
[INFO] Update available: 1.3.0 (current: 1.2.3)
|
|
||||||
[INFO] Run 'barn update' to install
|
|
||||||
```
|
|
||||||
|
|
||||||
This check is non-blocking and doesn't affect service startup.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
### Update Check Fails
|
|
||||||
|
|
||||||
```
|
|
||||||
Error: Failed to check for updates
|
|
||||||
GitHub API rate limit exceeded.
|
|
||||||
```
|
|
||||||
|
|
||||||
Solution: Wait an hour or authenticate with a GitHub token:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
GITHUB_TOKEN=xxx barn update --check
|
|
||||||
```
|
|
||||||
|
|
||||||
### Permission Denied
|
|
||||||
|
|
||||||
```
|
|
||||||
Error: Cannot write to /usr/local/bin/barn
|
|
||||||
```
|
|
||||||
|
|
||||||
Solution: Run with elevated privileges:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo barn update
|
|
||||||
```
|
|
||||||
|
|
||||||
### Binary Corrupted After Update
|
|
||||||
|
|
||||||
```
|
|
||||||
Error: barn: cannot execute binary file
|
|
||||||
```
|
|
||||||
|
|
||||||
Solution: Roll back and report the issue:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo mv /usr/local/bin/barn.backup /usr/local/bin/barn
|
|
||||||
barn --version # Verify rollback worked
|
|
||||||
```
|
|
||||||
|
|
||||||
### Service Won't Start After Update
|
|
||||||
|
|
||||||
1. Check logs: `barn service logs`
|
|
||||||
2. Roll back: `barn update --rollback`
|
|
||||||
3. Start service: `barn service start`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Implementation Details
|
|
||||||
|
|
||||||
### Version Detection
|
|
||||||
|
|
||||||
Barn determines its own version at compile time:
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
object Version {
|
|
||||||
const val CURRENT = "1.2.3" // Injected at build
|
|
||||||
val commit = System.getenv("BARN_COMMIT") ?: "unknown"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### API Endpoint
|
|
||||||
|
|
||||||
```
|
|
||||||
GET https://api.github.com/repos/samson-media/barn/releases/latest
|
|
||||||
Accept: application/vnd.github.v3+json
|
|
||||||
```
|
|
||||||
|
|
||||||
### Download with Progress
|
|
||||||
|
|
||||||
Downloads show progress for large binaries:
|
|
||||||
|
|
||||||
```
|
|
||||||
Downloading barn-linux-x64...
|
|
||||||
[████████████████████░░░░░░░░░░] 67% (12.3 MB / 18.4 MB)
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Next Steps
|
## Next Steps
|
||||||
|
|
||||||
- [Releasing](releasing.md) - How versions are published
|
- [Releasing](releasing.md) - How versions are published
|
||||||
- [Distribution](distribution.md) - Package manager alternatives
|
- [Distribution](distribution.md) - Installation methods by platform
|
||||||
+67
-484
@@ -8,524 +8,109 @@ This document describes package manager setup and installer creation for all sup
|
|||||||
|
|
||||||
| Platform | Package Format | Distribution Channel |
|
| Platform | Package Format | Distribution Channel |
|
||||||
|----------|---------------|---------------------|
|
|----------|---------------|---------------------|
|
||||||
| Windows | MSI installer | WinGet |
|
| Windows | Setup installer (.exe) | GitHub Releases |
|
||||||
| Linux (Debian/Ubuntu) | .deb | GitHub Releases, optional PPA |
|
| Linux | Native binary | GitHub Releases |
|
||||||
| Linux (Arch) | PKGBUILD | AUR |
|
|
||||||
| macOS | Formula | Homebrew tap |
|
| macOS | Formula | Homebrew tap |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Windows MSI
|
## Windows Setup Installer
|
||||||
|
|
||||||
### WiX Toolset Setup
|
### Download
|
||||||
|
|
||||||
Barn uses [WiX Toolset v4](https://wixtoolset.org/) to create MSI installers.
|
Download the latest setup installer from GitHub Releases:
|
||||||
|
|
||||||
Install WiX:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
dotnet tool install --global wix
|
|
||||||
```
|
|
||||||
|
|
||||||
### Package Structure
|
|
||||||
|
|
||||||
```
|
```
|
||||||
packaging/wix/
|
https://github.com/samson-media/barn/releases/download/v1.2.3/setup-barn-v1.2.3-windows-x64.exe
|
||||||
barn.wxs # WiX source file
|
|
||||||
license.rtf # License for installer
|
|
||||||
banner.png # Installer banner (optional)
|
|
||||||
dialog.png # Installer dialog background (optional)
|
|
||||||
```
|
|
||||||
|
|
||||||
### WiX Source File
|
|
||||||
|
|
||||||
File: `packaging/wix/barn.wxs`
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
|
|
||||||
<Package Name="Barn"
|
|
||||||
Version="!(bind.FileVersion.BarnExe)"
|
|
||||||
Manufacturer="Samson Media"
|
|
||||||
UpgradeCode="PUT-GUID-HERE"
|
|
||||||
Scope="perMachine">
|
|
||||||
|
|
||||||
<MajorUpgrade DowngradeErrorMessage="A newer version of Barn is already installed." />
|
|
||||||
<MediaTemplate EmbedCab="yes" />
|
|
||||||
|
|
||||||
<Feature Id="ProductFeature" Title="Barn" Level="1">
|
|
||||||
<ComponentGroupRef Id="ProductComponents" />
|
|
||||||
<ComponentGroupRef Id="ServiceComponents" />
|
|
||||||
</Feature>
|
|
||||||
|
|
||||||
<StandardDirectory Id="ProgramFiles64Folder">
|
|
||||||
<Directory Id="INSTALLFOLDER" Name="Barn">
|
|
||||||
<Component Id="BarnExe" Guid="PUT-GUID-HERE">
|
|
||||||
<File Id="BarnExe" Source="barn-windows-x64.exe" Name="barn.exe" KeyPath="yes" />
|
|
||||||
</Component>
|
|
||||||
|
|
||||||
<Component Id="PathEntry" Guid="PUT-GUID-HERE">
|
|
||||||
<Environment Id="PATH" Name="PATH" Value="[INSTALLFOLDER]"
|
|
||||||
Permanent="no" Part="last" Action="set" System="yes" />
|
|
||||||
</Component>
|
|
||||||
</Directory>
|
|
||||||
</StandardDirectory>
|
|
||||||
|
|
||||||
<ComponentGroup Id="ProductComponents">
|
|
||||||
<ComponentRef Id="BarnExe" />
|
|
||||||
<ComponentRef Id="PathEntry" />
|
|
||||||
</ComponentGroup>
|
|
||||||
|
|
||||||
<ComponentGroup Id="ServiceComponents">
|
|
||||||
<Component Id="BarnService" Directory="INSTALLFOLDER" Guid="PUT-GUID-HERE">
|
|
||||||
<ServiceInstall Id="BarnServiceInstall"
|
|
||||||
Type="ownProcess"
|
|
||||||
Name="BarnService"
|
|
||||||
DisplayName="Barn Job Daemon"
|
|
||||||
Description="Background service for managing media processing jobs"
|
|
||||||
Start="auto"
|
|
||||||
Account="LocalSystem"
|
|
||||||
ErrorControl="normal" />
|
|
||||||
<ServiceControl Id="StartBarnService"
|
|
||||||
Start="install"
|
|
||||||
Stop="both"
|
|
||||||
Remove="uninstall"
|
|
||||||
Name="BarnService"
|
|
||||||
Wait="yes" />
|
|
||||||
</Component>
|
|
||||||
</ComponentGroup>
|
|
||||||
</Package>
|
|
||||||
</Wix>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Building the MSI
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
cd packaging/wix
|
|
||||||
wix build -o barn-windows-x64.msi barn.wxs
|
|
||||||
```
|
|
||||||
|
|
||||||
### WinGet Submission
|
|
||||||
|
|
||||||
#### Manifest Structure
|
|
||||||
|
|
||||||
Create a manifest directory:
|
|
||||||
|
|
||||||
```
|
|
||||||
manifests/s/SamsonMedia/Barn/1.2.3/
|
|
||||||
SamsonMedia.Barn.yaml
|
|
||||||
SamsonMedia.Barn.installer.yaml
|
|
||||||
SamsonMedia.Barn.locale.en-US.yaml
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Version Manifest
|
|
||||||
|
|
||||||
File: `SamsonMedia.Barn.yaml`
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
PackageIdentifier: SamsonMedia.Barn
|
|
||||||
PackageVersion: 1.2.3
|
|
||||||
DefaultLocale: en-US
|
|
||||||
ManifestType: version
|
|
||||||
ManifestVersion: 1.6.0
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Installer Manifest
|
|
||||||
|
|
||||||
File: `SamsonMedia.Barn.installer.yaml`
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
PackageIdentifier: SamsonMedia.Barn
|
|
||||||
PackageVersion: 1.2.3
|
|
||||||
Platform:
|
|
||||||
- Windows.Desktop
|
|
||||||
MinimumOSVersion: 10.0.0.0
|
|
||||||
InstallerType: msi
|
|
||||||
Scope: machine
|
|
||||||
InstallModes:
|
|
||||||
- silent
|
|
||||||
- silentWithProgress
|
|
||||||
Installers:
|
|
||||||
- Architecture: x64
|
|
||||||
InstallerUrl: https://github.com/samson-media/barn/releases/download/v1.2.3/barn-windows-x64.msi
|
|
||||||
InstallerSha256: <SHA256_HASH>
|
|
||||||
ManifestType: installer
|
|
||||||
ManifestVersion: 1.6.0
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Locale Manifest
|
|
||||||
|
|
||||||
File: `SamsonMedia.Barn.locale.en-US.yaml`
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
PackageIdentifier: SamsonMedia.Barn
|
|
||||||
PackageVersion: 1.2.3
|
|
||||||
PackageLocale: en-US
|
|
||||||
Publisher: Samson Media
|
|
||||||
PackageName: Barn
|
|
||||||
PackageUrl: https://github.com/samson-media/barn
|
|
||||||
License: MIT
|
|
||||||
ShortDescription: Cross-platform job daemon for media processing
|
|
||||||
Description: A cross-platform service for managing long-running jobs involving media download, upload, and FFmpeg processing.
|
|
||||||
Tags:
|
|
||||||
- cli
|
|
||||||
- ffmpeg
|
|
||||||
- media
|
|
||||||
- daemon
|
|
||||||
- job-scheduler
|
|
||||||
ManifestType: defaultLocale
|
|
||||||
ManifestVersion: 1.6.0
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Submitting to WinGet
|
|
||||||
|
|
||||||
1. Fork [microsoft/winget-pkgs](https://github.com/microsoft/winget-pkgs)
|
|
||||||
2. Create branch: `barn-1.2.3`
|
|
||||||
3. Add manifest files to `manifests/s/SamsonMedia/Barn/1.2.3/`
|
|
||||||
4. Validate: `winget validate manifests/s/SamsonMedia/Barn/1.2.3/`
|
|
||||||
5. Create pull request
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Linux .deb (apt)
|
|
||||||
|
|
||||||
### Package Structure
|
|
||||||
|
|
||||||
```
|
|
||||||
packaging/deb/
|
|
||||||
DEBIAN/
|
|
||||||
control
|
|
||||||
postinst
|
|
||||||
prerm
|
|
||||||
conffiles
|
|
||||||
usr/
|
|
||||||
bin/
|
|
||||||
barn
|
|
||||||
lib/
|
|
||||||
systemd/
|
|
||||||
system/
|
|
||||||
barn.service
|
|
||||||
etc/
|
|
||||||
barn/
|
|
||||||
barn.conf
|
|
||||||
```
|
|
||||||
|
|
||||||
### Control File
|
|
||||||
|
|
||||||
File: `packaging/deb/DEBIAN/control`
|
|
||||||
|
|
||||||
```
|
|
||||||
Package: barn
|
|
||||||
Version: 1.2.3
|
|
||||||
Section: utils
|
|
||||||
Priority: optional
|
|
||||||
Architecture: amd64
|
|
||||||
Maintainer: Samson Media <support@samson-media.com>
|
|
||||||
Description: Cross-platform job daemon for media processing
|
|
||||||
A cross-platform service for managing long-running jobs involving
|
|
||||||
media download, upload, and FFmpeg processing with strong guarantees
|
|
||||||
around durability, observability, and crash recovery.
|
|
||||||
Homepage: https://github.com/samson-media/barn
|
|
||||||
Depends: libc6 (>= 2.31)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Post-Install Script
|
|
||||||
|
|
||||||
File: `packaging/deb/DEBIAN/postinst`
|
|
||||||
|
|
||||||
```bash
|
|
||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Reload systemd
|
|
||||||
systemctl daemon-reload
|
|
||||||
|
|
||||||
# Enable and start service
|
|
||||||
systemctl enable barn.service
|
|
||||||
systemctl start barn.service
|
|
||||||
|
|
||||||
echo "Barn installed successfully. Service is running."
|
|
||||||
echo "Run 'barn status' to check job status."
|
|
||||||
```
|
|
||||||
|
|
||||||
### Pre-Remove Script
|
|
||||||
|
|
||||||
File: `packaging/deb/DEBIAN/prerm`
|
|
||||||
|
|
||||||
```bash
|
|
||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Stop and disable service
|
|
||||||
systemctl stop barn.service || true
|
|
||||||
systemctl disable barn.service || true
|
|
||||||
|
|
||||||
echo "Barn service stopped."
|
|
||||||
```
|
|
||||||
|
|
||||||
### Systemd Service File
|
|
||||||
|
|
||||||
File: `packaging/deb/lib/systemd/system/barn.service`
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[Unit]
|
|
||||||
Description=Barn Job Daemon
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
ExecStart=/usr/bin/barn service run
|
|
||||||
ExecReload=/bin/kill -HUP $MAINPID
|
|
||||||
Restart=on-failure
|
|
||||||
RestartSec=5
|
|
||||||
User=root
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
```
|
|
||||||
|
|
||||||
### Building the .deb
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Set permissions
|
|
||||||
chmod 755 packaging/deb/DEBIAN/postinst
|
|
||||||
chmod 755 packaging/deb/DEBIAN/prerm
|
|
||||||
chmod 755 packaging/deb/usr/bin/barn
|
|
||||||
|
|
||||||
# Build package
|
|
||||||
dpkg-deb --build packaging/deb barn-linux-x64.deb
|
|
||||||
|
|
||||||
# Verify
|
|
||||||
dpkg-deb --info barn-linux-x64.deb
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
Users install directly from GitHub Releases:
|
1. Download `setup-barn-vX.X.X-windows-x64.exe` from the [releases page](https://github.com/samson-media/barn/releases/latest)
|
||||||
|
2. Run the installer (requires Administrator privileges)
|
||||||
|
3. The installer will:
|
||||||
|
- Install `barn.exe` to `C:\Program Files\Barn\`
|
||||||
|
- Add Barn to the system PATH
|
||||||
|
- Install and start the Barn Windows Service
|
||||||
|
|
||||||
```bash
|
### Silent Installation
|
||||||
# Download
|
|
||||||
wget https://github.com/samson-media/barn/releases/download/v1.2.3/barn-linux-x64.deb
|
|
||||||
|
|
||||||
# Install
|
For automated deployments:
|
||||||
sudo dpkg -i barn-linux-x64.deb
|
|
||||||
|
|
||||||
# Or with apt (handles dependencies)
|
```powershell
|
||||||
sudo apt install ./barn-linux-x64.deb
|
.\setup-barn-v1.2.3-windows-x64.exe /S
|
||||||
```
|
```
|
||||||
|
|
||||||
### Optional: Launchpad PPA
|
### Uninstallation
|
||||||
|
|
||||||
For automatic updates via apt:
|
Use Windows Settings → Apps → Barn, or run:
|
||||||
|
|
||||||
1. Create account at [Launchpad](https://launchpad.net/)
|
```powershell
|
||||||
2. Create PPA: `ppa:samson-media/barn`
|
"C:\Program Files\Barn\uninstall.exe" /S
|
||||||
3. Upload source package with `dput`
|
```
|
||||||
4. Users add: `sudo add-apt-repository ppa:samson-media/barn`
|
|
||||||
|
### Updating
|
||||||
|
|
||||||
|
To update Barn on Windows:
|
||||||
|
|
||||||
|
1. Download the latest setup installer
|
||||||
|
2. Run the installer - it will automatically stop the service, update the binary, and restart the service
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Linux PKGBUILD (pacman/AUR)
|
## Linux
|
||||||
|
|
||||||
### PKGBUILD File
|
Linux users install Barn by downloading the native binary directly from GitHub Releases.
|
||||||
|
|
||||||
File: `packaging/aur/PKGBUILD`
|
### Download
|
||||||
|
|
||||||
|
Download the appropriate binary for your architecture:
|
||||||
|
|
||||||
|
- **x86_64**: `barn-linux-x64`
|
||||||
|
- **ARM64**: `barn-linux-arm64`
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Maintainer: Samson Media <support@samson-media.com>
|
# Download (x86_64 example)
|
||||||
pkgname=barn
|
curl -LO https://github.com/samson-media/barn/releases/download/v1.2.3/barn-linux-x64
|
||||||
pkgver=1.2.3
|
|
||||||
pkgrel=1
|
|
||||||
pkgdesc="Cross-platform job daemon for media processing"
|
|
||||||
arch=('x86_64' 'aarch64')
|
|
||||||
url="https://github.com/samson-media/barn"
|
|
||||||
license=('MIT')
|
|
||||||
depends=('glibc')
|
|
||||||
provides=('barn')
|
|
||||||
conflicts=('barn-git')
|
|
||||||
source_x86_64=("${pkgname}-${pkgver}-x86_64::https://github.com/samson-media/barn/releases/download/v${pkgver}/barn-linux-x64")
|
|
||||||
source_aarch64=("${pkgname}-${pkgver}-aarch64::https://github.com/samson-media/barn/releases/download/v${pkgver}/barn-linux-arm64")
|
|
||||||
sha256sums_x86_64=('SKIP') # Replace with actual hash
|
|
||||||
sha256sums_aarch64=('SKIP') # Replace with actual hash
|
|
||||||
|
|
||||||
package() {
|
# Verify checksum
|
||||||
install -Dm755 "${srcdir}/${pkgname}-${pkgver}-${CARCH}" "${pkgdir}/usr/bin/barn"
|
curl -LO https://github.com/samson-media/barn/releases/download/v1.2.3/SHA256SUMS
|
||||||
install -Dm644 "${srcdir}/barn.service" "${pkgdir}/usr/lib/systemd/system/barn.service"
|
sha256sum -c SHA256SUMS --ignore-missing
|
||||||
}
|
|
||||||
|
# Install
|
||||||
|
chmod +x barn-linux-x64
|
||||||
|
sudo mv barn-linux-x64 /usr/local/bin/barn
|
||||||
|
|
||||||
|
# Verify
|
||||||
|
barn --version
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install Script
|
### Setting Up the Service
|
||||||
|
|
||||||
File: `packaging/aur/barn.install`
|
After installing the binary, set up the systemd service:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
post_install() {
|
# Install the service
|
||||||
systemctl daemon-reload
|
barn service install
|
||||||
echo ":: Run 'systemctl enable --now barn.service' to start Barn"
|
|
||||||
}
|
|
||||||
|
|
||||||
post_upgrade() {
|
# Enable and start the service
|
||||||
systemctl daemon-reload
|
sudo systemctl enable barn
|
||||||
systemctl try-restart barn.service
|
sudo systemctl start barn
|
||||||
}
|
|
||||||
|
|
||||||
pre_remove() {
|
# Verify
|
||||||
systemctl stop barn.service || true
|
barn service status
|
||||||
systemctl disable barn.service || true
|
|
||||||
}
|
|
||||||
|
|
||||||
post_remove() {
|
|
||||||
systemctl daemon-reload
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### AUR Submission
|
### Updating
|
||||||
|
|
||||||
1. Create account at [AUR](https://aur.archlinux.org/)
|
To update Barn on Linux:
|
||||||
2. Add SSH key to account
|
|
||||||
3. Clone AUR package base:
|
|
||||||
```bash
|
|
||||||
git clone ssh://aur@aur.archlinux.org/barn.git
|
|
||||||
```
|
|
||||||
4. Add PKGBUILD and .SRCINFO:
|
|
||||||
```bash
|
|
||||||
makepkg --printsrcinfo > .SRCINFO
|
|
||||||
```
|
|
||||||
5. Commit and push:
|
|
||||||
```bash
|
|
||||||
git add PKGBUILD .SRCINFO barn.install
|
|
||||||
git commit -m "Update to version 1.2.3"
|
|
||||||
git push
|
|
||||||
```
|
|
||||||
|
|
||||||
### Updating AUR Package
|
1. Download the new binary from GitHub Releases
|
||||||
|
2. Stop the service: `sudo systemctl stop barn`
|
||||||
AUR updates are **automated** via GitHub Actions. See [CI/CD](ci-cd.md#aur-update-workflow) for the workflow details.
|
3. Replace the binary: `sudo mv barn-linux-x64 /usr/local/bin/barn`
|
||||||
|
4. Start the service: `sudo systemctl start barn`
|
||||||
If manual update is needed:
|
|
||||||
|
|
||||||
1. Update `pkgver` in PKGBUILD
|
|
||||||
2. Update SHA256 checksums
|
|
||||||
3. Regenerate .SRCINFO
|
|
||||||
4. Commit and push
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Clone the AUR repo
|
|
||||||
git clone ssh://aur@aur.archlinux.org/barn.git aur-barn
|
|
||||||
cd aur-barn
|
|
||||||
|
|
||||||
# Update version
|
|
||||||
sed -i "s/pkgver=.*/pkgver=1.2.4/" PKGBUILD
|
|
||||||
|
|
||||||
# Get new checksums from GitHub release
|
|
||||||
curl -sL https://github.com/samson-media/barn/releases/download/v1.2.4/SHA256SUMS
|
|
||||||
|
|
||||||
# Update checksums in PKGBUILD
|
|
||||||
# Edit sha256sums_x86_64 and sha256sums_aarch64
|
|
||||||
|
|
||||||
# Regenerate .SRCINFO
|
|
||||||
makepkg --printsrcinfo > .SRCINFO
|
|
||||||
|
|
||||||
# Commit and push
|
|
||||||
git add PKGBUILD .SRCINFO
|
|
||||||
git commit -m "Update to version 1.2.4"
|
|
||||||
git push
|
|
||||||
```
|
|
||||||
|
|
||||||
### Initial AUR Setup
|
|
||||||
|
|
||||||
Before the first release, create the AUR package:
|
|
||||||
|
|
||||||
1. **Create AUR Account**
|
|
||||||
- Register at https://aur.archlinux.org/register/
|
|
||||||
- Verify email and log in
|
|
||||||
|
|
||||||
2. **Add SSH Key**
|
|
||||||
```bash
|
|
||||||
ssh-keygen -t ed25519 -C "aur" -f ~/.ssh/aur
|
|
||||||
```
|
|
||||||
- Add public key at https://aur.archlinux.org/account/
|
|
||||||
- Configure SSH:
|
|
||||||
```
|
|
||||||
# ~/.ssh/config
|
|
||||||
Host aur.archlinux.org
|
|
||||||
IdentityFile ~/.ssh/aur
|
|
||||||
User aur
|
|
||||||
```
|
|
||||||
|
|
||||||
3. **Create Package Base**
|
|
||||||
```bash
|
|
||||||
git clone ssh://aur@aur.archlinux.org/barn.git
|
|
||||||
cd barn
|
|
||||||
# Directory will be empty for new packages
|
|
||||||
```
|
|
||||||
|
|
||||||
4. **Add Package Files**
|
|
||||||
```bash
|
|
||||||
# Copy PKGBUILD, barn.install, barn.service from packaging/aur/
|
|
||||||
cp /path/to/packaging/aur/* .
|
|
||||||
|
|
||||||
# Generate .SRCINFO
|
|
||||||
makepkg --printsrcinfo > .SRCINFO
|
|
||||||
|
|
||||||
# Initial commit
|
|
||||||
git add PKGBUILD .SRCINFO barn.install barn.service
|
|
||||||
git commit -m "Initial package submission"
|
|
||||||
git push
|
|
||||||
```
|
|
||||||
|
|
||||||
5. **Verify Package**
|
|
||||||
- Check https://aur.archlinux.org/packages/barn
|
|
||||||
- Test installation:
|
|
||||||
```bash
|
|
||||||
yay -S barn # or paru -S barn
|
|
||||||
```
|
|
||||||
|
|
||||||
### AUR Best Practices
|
|
||||||
|
|
||||||
- **Test locally** before pushing: `makepkg -si`
|
|
||||||
- **Bump pkgrel** for packaging changes (same upstream version)
|
|
||||||
- **Reset pkgrel to 1** when pkgver changes
|
|
||||||
- **Respond to comments** on AUR package page
|
|
||||||
- **Flag out-of-date** packages if automation fails
|
|
||||||
|
|
||||||
### barn-git Package (Optional)
|
|
||||||
|
|
||||||
For users who want the latest development version, consider maintaining a `-git` package:
|
|
||||||
|
|
||||||
File: `packaging/aur-git/PKGBUILD`
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Maintainer: Samson Media <support@samson-media.com>
|
|
||||||
pkgname=barn-git
|
|
||||||
pkgver=r123.abc1234
|
|
||||||
pkgrel=1
|
|
||||||
pkgdesc="Cross-platform job daemon for media processing (development version)"
|
|
||||||
arch=('x86_64' 'aarch64')
|
|
||||||
url="https://github.com/samson-media/barn"
|
|
||||||
license=('MIT')
|
|
||||||
depends=('glibc')
|
|
||||||
makedepends=('git' 'graalvm-jdk' 'gradle')
|
|
||||||
provides=('barn')
|
|
||||||
conflicts=('barn')
|
|
||||||
source=("git+https://github.com/samson-media/barn.git")
|
|
||||||
sha256sums=('SKIP')
|
|
||||||
|
|
||||||
pkgver() {
|
|
||||||
cd barn
|
|
||||||
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
|
||||||
}
|
|
||||||
|
|
||||||
build() {
|
|
||||||
cd barn
|
|
||||||
./gradlew nativeCompile
|
|
||||||
}
|
|
||||||
|
|
||||||
package() {
|
|
||||||
cd barn
|
|
||||||
install -Dm755 "build/native/nativeCompile/barn" "${pkgdir}/usr/bin/barn"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -676,10 +261,8 @@ barn --version
|
|||||||
|
|
||||||
After publishing a GitHub Release:
|
After publishing a GitHub Release:
|
||||||
|
|
||||||
1. **Windows**: Submit WinGet manifest PR
|
1. **Homebrew**: Formula auto-updates via GitHub Actions workflow
|
||||||
2. **Arch Linux**: Update AUR PKGBUILD
|
2. **Windows/Linux**: Binaries and setup installer available on GitHub Releases (manual download)
|
||||||
3. **Homebrew**: Formula auto-updates via workflow
|
|
||||||
4. **Debian**: .deb available on GitHub Releases
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.samsonmedia</groupId>
|
<groupId>com.samsonmedia</groupId>
|
||||||
<artifactId>barn</artifactId>
|
<artifactId>barn</artifactId>
|
||||||
<version>0.1.2</version>
|
<version>0.1.4</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Barn</name>
|
<name>Barn</name>
|
||||||
@@ -39,14 +39,13 @@
|
|||||||
<maven-shade-plugin.version>3.6.0</maven-shade-plugin.version>
|
<maven-shade-plugin.version>3.6.0</maven-shade-plugin.version>
|
||||||
<checkstyle-plugin.version>3.6.0</checkstyle-plugin.version>
|
<checkstyle-plugin.version>3.6.0</checkstyle-plugin.version>
|
||||||
<checkstyle.version>10.21.1</checkstyle.version>
|
<checkstyle.version>10.21.1</checkstyle.version>
|
||||||
<spotbugs-plugin.version>4.9.3.0</spotbugs-plugin.version>
|
<spotbugs-plugin.version>4.9.8.2</spotbugs-plugin.version>
|
||||||
<pmd-plugin.version>3.26.0</pmd-plugin.version>
|
|
||||||
<jacoco-plugin.version>0.8.12</jacoco-plugin.version>
|
<jacoco-plugin.version>0.8.12</jacoco-plugin.version>
|
||||||
<native-maven-plugin.version>0.10.4</native-maven-plugin.version>
|
<native-maven-plugin.version>0.10.4</native-maven-plugin.version>
|
||||||
|
|
||||||
<!-- Code Quality Thresholds -->
|
<!-- Code Quality Thresholds -->
|
||||||
<jacoco.line.coverage>0.68</jacoco.line.coverage>
|
<jacoco.line.coverage>0.68</jacoco.line.coverage>
|
||||||
<jacoco.branch.coverage>0.58</jacoco.branch.coverage>
|
<jacoco.branch.coverage>0.57</jacoco.branch.coverage>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -90,7 +89,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.spotbugs</groupId>
|
<groupId>com.github.spotbugs</groupId>
|
||||||
<artifactId>spotbugs-annotations</artifactId>
|
<artifactId>spotbugs-annotations</artifactId>
|
||||||
<version>4.8.6</version>
|
<version>4.9.8</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -287,31 +286,6 @@
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!-- PMD - Static Analysis -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-pmd-plugin</artifactId>
|
|
||||||
<version>${pmd-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<rulesets>
|
|
||||||
<ruleset>config/pmd/ruleset.xml</ruleset>
|
|
||||||
</rulesets>
|
|
||||||
<failOnViolation>true</failOnViolation>
|
|
||||||
<printFailingErrors>true</printFailingErrors>
|
|
||||||
<includeTests>true</includeTests>
|
|
||||||
<targetJdk>${maven.compiler.target}</targetJdk>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>pmd-check</id>
|
|
||||||
<phase>verify</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>check</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<!-- JaCoCo - Code Coverage -->
|
<!-- JaCoCo - Code Coverage -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jacoco</groupId>
|
<groupId>org.jacoco</groupId>
|
||||||
@@ -407,7 +381,6 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<checkstyle.skip>true</checkstyle.skip>
|
<checkstyle.skip>true</checkstyle.skip>
|
||||||
<spotbugs.skip>true</spotbugs.skip>
|
<spotbugs.skip>true</spotbugs.skip>
|
||||||
<pmd.skip>true</pmd.skip>
|
|
||||||
<jacoco.skip>true</jacoco.skip>
|
<jacoco.skip>true</jacoco.skip>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
@@ -432,11 +405,6 @@
|
|||||||
<artifactId>spotbugs-maven-plugin</artifactId>
|
<artifactId>spotbugs-maven-plugin</artifactId>
|
||||||
<version>${spotbugs-plugin.version}</version>
|
<version>${spotbugs-plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-pmd-plugin</artifactId>
|
|
||||||
<version>${pmd-plugin.version}</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jacoco</groupId>
|
<groupId>org.jacoco</groupId>
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
@@ -24,6 +21,7 @@ import com.samsonmedia.barn.ipc.IpcClient;
|
|||||||
import com.samsonmedia.barn.ipc.IpcException;
|
import com.samsonmedia.barn.ipc.IpcException;
|
||||||
import com.samsonmedia.barn.jobs.Job;
|
import com.samsonmedia.barn.jobs.Job;
|
||||||
import com.samsonmedia.barn.jobs.JobRepository;
|
import com.samsonmedia.barn.jobs.JobRepository;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.state.BarnDirectories;
|
import com.samsonmedia.barn.state.BarnDirectories;
|
||||||
import com.samsonmedia.barn.state.JobState;
|
import com.samsonmedia.barn.state.JobState;
|
||||||
import com.samsonmedia.barn.util.DurationParser;
|
import com.samsonmedia.barn.util.DurationParser;
|
||||||
@@ -41,7 +39,7 @@ import picocli.CommandLine.Option;
|
|||||||
)
|
)
|
||||||
public class CleanCommand extends BaseCommand {
|
public class CleanCommand extends BaseCommand {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(CleanCommand.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(CleanCommand.class);
|
||||||
|
|
||||||
@Option(names = {"--all"}, description = "Remove all completed jobs regardless of age")
|
@Option(names = {"--all"}, description = "Remove all completed jobs regardless of age")
|
||||||
private boolean all;
|
private boolean all;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.samsonmedia.barn.cli;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.CleanupConfig;
|
import com.samsonmedia.barn.config.CleanupConfig;
|
||||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||||
@@ -71,7 +72,7 @@ public class ConfigInitCommand extends BaseCommand {
|
|||||||
sb.append("[service]\n");
|
sb.append("[service]\n");
|
||||||
sb.append("# Logging verbosity: debug, info, warn, error\n");
|
sb.append("# Logging verbosity: debug, info, warn, error\n");
|
||||||
sb.append(String.format("log_level = \"%s\"%n",
|
sb.append(String.format("log_level = \"%s\"%n",
|
||||||
ServiceConfig.DEFAULT_LOG_LEVEL.toString().toLowerCase()));
|
ServiceConfig.DEFAULT_LOG_LEVEL.toString().toLowerCase(Locale.ROOT)));
|
||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
sb.append("# Maximum jobs running simultaneously\n");
|
sb.append("# Maximum jobs running simultaneously\n");
|
||||||
sb.append(String.format("max_concurrent_jobs = %d%n", ServiceConfig.DEFAULT_MAX_CONCURRENT_JOBS));
|
sb.append(String.format("max_concurrent_jobs = %d%n", ServiceConfig.DEFAULT_MAX_CONCURRENT_JOBS));
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.samsonmedia.barn.cli;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -49,8 +50,7 @@ public class ConfigShowCommand extends BaseCommand {
|
|||||||
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case HUMAN -> outputHumanFormat(config, effectiveConfigFile);
|
case HUMAN -> outputHumanFormat(config, effectiveConfigFile);
|
||||||
case JSON -> output(toMap(config));
|
case JSON, XML -> output(toMap(config));
|
||||||
case XML -> output(toMap(config));
|
|
||||||
default -> outputHumanFormat(config, effectiveConfigFile);
|
default -> outputHumanFormat(config, effectiveConfigFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ public class ConfigShowCommand extends BaseCommand {
|
|||||||
|
|
||||||
// Service section
|
// Service section
|
||||||
sb.append("[service]\n");
|
sb.append("[service]\n");
|
||||||
sb.append(String.format("log_level = %s%n", config.service().logLevel().toString().toLowerCase()));
|
sb.append(String.format("log_level = %s%n", config.service().logLevel().toString().toLowerCase(Locale.ROOT)));
|
||||||
sb.append(String.format("max_concurrent_jobs = %d%n", config.service().maxConcurrentJobs()));
|
sb.append(String.format("max_concurrent_jobs = %d%n", config.service().maxConcurrentJobs()));
|
||||||
sb.append(String.format("heartbeat_interval_seconds = %d%n", config.service().heartbeatIntervalSeconds()));
|
sb.append(String.format("heartbeat_interval_seconds = %d%n", config.service().heartbeatIntervalSeconds()));
|
||||||
sb.append(String.format("ipc_socket = %s%n", config.service().ipcSocket()));
|
sb.append(String.format("ipc_socket = %s%n", config.service().ipcSocket()));
|
||||||
@@ -136,7 +136,7 @@ public class ConfigShowCommand extends BaseCommand {
|
|||||||
|
|
||||||
private Map<String, Object> buildServiceSection(Config config) {
|
private Map<String, Object> buildServiceSection(Config config) {
|
||||||
Map<String, Object> service = new LinkedHashMap<>();
|
Map<String, Object> service = new LinkedHashMap<>();
|
||||||
service.put("log_level", config.service().logLevel().toString().toLowerCase());
|
service.put("log_level", config.service().logLevel().toString().toLowerCase(Locale.ROOT));
|
||||||
service.put("max_concurrent_jobs", config.service().maxConcurrentJobs());
|
service.put("max_concurrent_jobs", config.service().maxConcurrentJobs());
|
||||||
service.put("heartbeat_interval_seconds", config.service().heartbeatIntervalSeconds());
|
service.put("heartbeat_interval_seconds", config.service().heartbeatIntervalSeconds());
|
||||||
service.put("ipc_socket", config.service().ipcSocket().toString());
|
service.put("ipc_socket", config.service().ipcSocket().toString());
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -225,7 +226,7 @@ public class ConfigValidateCommand extends BaseCommand {
|
|||||||
if (section.containsKey(key)) {
|
if (section.containsKey(key)) {
|
||||||
Object value = section.get(key);
|
Object value = section.get(key);
|
||||||
if (!(value instanceof Boolean)) {
|
if (!(value instanceof Boolean)) {
|
||||||
String strValue = value.toString().toLowerCase();
|
String strValue = value.toString().toLowerCase(Locale.ROOT);
|
||||||
if (!strValue.equals("true") && !strValue.equals("false")) {
|
if (!strValue.equals("true") && !strValue.equals("false")) {
|
||||||
errors.add(new ValidationError(0, key,
|
errors.add(new ValidationError(0, key,
|
||||||
"Invalid value for '" + key + "': must be true or false"));
|
"Invalid value for '" + key + "': must be true or false"));
|
||||||
|
|||||||
@@ -9,14 +9,12 @@ import java.time.ZoneId;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
@@ -26,6 +24,7 @@ import com.samsonmedia.barn.ipc.IpcException;
|
|||||||
import com.samsonmedia.barn.jobs.Job;
|
import com.samsonmedia.barn.jobs.Job;
|
||||||
import com.samsonmedia.barn.jobs.JobManifest;
|
import com.samsonmedia.barn.jobs.JobManifest;
|
||||||
import com.samsonmedia.barn.jobs.JobRepository;
|
import com.samsonmedia.barn.jobs.JobRepository;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.state.BarnDirectories;
|
import com.samsonmedia.barn.state.BarnDirectories;
|
||||||
|
|
||||||
import picocli.CommandLine.Command;
|
import picocli.CommandLine.Command;
|
||||||
@@ -42,7 +41,7 @@ import picocli.CommandLine.Parameters;
|
|||||||
)
|
)
|
||||||
public class DescribeCommand extends BaseCommand {
|
public class DescribeCommand extends BaseCommand {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(DescribeCommand.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(DescribeCommand.class);
|
||||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
|
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
|
||||||
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
@@ -169,7 +168,7 @@ public class DescribeCommand extends BaseCommand {
|
|||||||
sb.append("================================================================================\n");
|
sb.append("================================================================================\n");
|
||||||
|
|
||||||
// Basic info
|
// Basic info
|
||||||
sb.append("State: ").append(job.state().toString().toLowerCase()).append("\n");
|
sb.append("State: ").append(job.state().toString().toLowerCase(Locale.ROOT)).append("\n");
|
||||||
if (job.tag() != null) {
|
if (job.tag() != null) {
|
||||||
sb.append("Tag: ").append(job.tag()).append("\n");
|
sb.append("Tag: ").append(job.tag()).append("\n");
|
||||||
}
|
}
|
||||||
@@ -239,7 +238,7 @@ public class DescribeCommand extends BaseCommand {
|
|||||||
|
|
||||||
// Job details
|
// Job details
|
||||||
response.put("id", job.id());
|
response.put("id", job.id());
|
||||||
response.put("state", job.state().toString().toLowerCase());
|
response.put("state", job.state().toString().toLowerCase(Locale.ROOT));
|
||||||
response.put("tag", job.tag());
|
response.put("tag", job.tag());
|
||||||
response.put("command", job.command());
|
response.put("command", job.command());
|
||||||
response.put("createdAt", job.createdAt());
|
response.put("createdAt", job.createdAt());
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.time.ZoneId;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.samsonmedia.barn.jobs.Job;
|
import com.samsonmedia.barn.jobs.Job;
|
||||||
@@ -145,7 +146,7 @@ public class HumanFormatter implements OutputFormatter {
|
|||||||
for (Job job : jobs) {
|
for (Job job : jobs) {
|
||||||
rows.add(List.of(
|
rows.add(List.of(
|
||||||
job.id(),
|
job.id(),
|
||||||
job.state().toString().toLowerCase(),
|
job.state().toString().toLowerCase(Locale.ROOT),
|
||||||
job.tag() != null ? job.tag() : "-",
|
job.tag() != null ? job.tag() : "-",
|
||||||
formatTimestamp(job.createdAt()),
|
formatTimestamp(job.createdAt()),
|
||||||
job.exitCode() != null ? job.exitCode().toString() : "-"
|
job.exitCode() != null ? job.exitCode().toString() : "-"
|
||||||
@@ -229,7 +230,7 @@ public class HumanFormatter implements OutputFormatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String colorizeState(JobState state) {
|
private String colorizeState(JobState state) {
|
||||||
return colorizeState(state, state.toString().toLowerCase());
|
return colorizeState(state, state.toString().toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String colorizeState(JobState state, String text) {
|
private String colorizeState(JobState state, String text) {
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
@@ -18,6 +15,7 @@ import com.samsonmedia.barn.ipc.IpcClient;
|
|||||||
import com.samsonmedia.barn.ipc.IpcException;
|
import com.samsonmedia.barn.ipc.IpcException;
|
||||||
import com.samsonmedia.barn.jobs.Job;
|
import com.samsonmedia.barn.jobs.Job;
|
||||||
import com.samsonmedia.barn.jobs.JobRepository;
|
import com.samsonmedia.barn.jobs.JobRepository;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.state.BarnDirectories;
|
import com.samsonmedia.barn.state.BarnDirectories;
|
||||||
import com.samsonmedia.barn.state.JobState;
|
import com.samsonmedia.barn.state.JobState;
|
||||||
|
|
||||||
@@ -35,7 +33,7 @@ import picocli.CommandLine.Parameters;
|
|||||||
)
|
)
|
||||||
public class KillCommand extends BaseCommand {
|
public class KillCommand extends BaseCommand {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(KillCommand.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(KillCommand.class);
|
||||||
|
|
||||||
@Parameters(index = "0", description = "Job ID")
|
@Parameters(index = "0", description = "Job ID")
|
||||||
private String jobId;
|
private String jobId;
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
@@ -18,6 +16,7 @@ import com.samsonmedia.barn.ipc.IpcClient;
|
|||||||
import com.samsonmedia.barn.ipc.IpcException;
|
import com.samsonmedia.barn.ipc.IpcException;
|
||||||
import com.samsonmedia.barn.jobs.Job;
|
import com.samsonmedia.barn.jobs.Job;
|
||||||
import com.samsonmedia.barn.jobs.JobRepository;
|
import com.samsonmedia.barn.jobs.JobRepository;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.state.BarnDirectories;
|
import com.samsonmedia.barn.state.BarnDirectories;
|
||||||
|
|
||||||
import picocli.CommandLine.Command;
|
import picocli.CommandLine.Command;
|
||||||
@@ -37,7 +36,7 @@ import picocli.CommandLine.Parameters;
|
|||||||
)
|
)
|
||||||
public class RunCommand extends BaseCommand {
|
public class RunCommand extends BaseCommand {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(RunCommand.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(RunCommand.class);
|
||||||
|
|
||||||
@Option(names = {"--tag", "-t"}, description = "Tag for filtering jobs")
|
@Option(names = {"--tag", "-t"}, description = "Tag for filtering jobs")
|
||||||
private String tag;
|
private String tag;
|
||||||
@@ -190,7 +189,7 @@ public class RunCommand extends BaseCommand {
|
|||||||
sb.append("Job created: ").append(job.id()).append("\n");
|
sb.append("Job created: ").append(job.id()).append("\n");
|
||||||
sb.append(" Command: ").append(String.join(" ", job.command())).append("\n");
|
sb.append(" Command: ").append(String.join(" ", job.command())).append("\n");
|
||||||
sb.append(" Tag: ").append(job.tag() != null ? job.tag() : "-").append("\n");
|
sb.append(" Tag: ").append(job.tag() != null ? job.tag() : "-").append("\n");
|
||||||
sb.append(" State: ").append(job.state().toString().toLowerCase());
|
sb.append(" State: ").append(job.state().toString().toLowerCase(Locale.ROOT));
|
||||||
|
|
||||||
getOut().println(sb.toString());
|
getOut().println(sb.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||||
import com.samsonmedia.barn.config.OperatingSystem;
|
import com.samsonmedia.barn.config.OperatingSystem;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.platform.linux.SystemdManager;
|
import com.samsonmedia.barn.platform.linux.SystemdManager;
|
||||||
import com.samsonmedia.barn.platform.macos.LaunchdManager;
|
import com.samsonmedia.barn.platform.macos.LaunchdManager;
|
||||||
import com.samsonmedia.barn.platform.windows.WindowsServiceManager;
|
import com.samsonmedia.barn.platform.windows.WindowsServiceManager;
|
||||||
@@ -33,7 +31,7 @@ import picocli.CommandLine.Option;
|
|||||||
)
|
)
|
||||||
public class ServiceInstallCommand extends BaseCommand {
|
public class ServiceInstallCommand extends BaseCommand {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceInstallCommand.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceInstallCommand.class);
|
||||||
|
|
||||||
@Option(names = {"--user"}, description = "Install as user service instead of system-wide")
|
@Option(names = {"--user"}, description = "Install as user service instead of system-wide")
|
||||||
private boolean userService;
|
private boolean userService;
|
||||||
|
|||||||
@@ -8,10 +8,8 @@ import java.nio.file.Path;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
|
|
||||||
import picocli.CommandLine.Command;
|
import picocli.CommandLine.Command;
|
||||||
import picocli.CommandLine.Option;
|
import picocli.CommandLine.Option;
|
||||||
@@ -26,7 +24,7 @@ import picocli.CommandLine.Option;
|
|||||||
)
|
)
|
||||||
public class ServiceLogsCommand extends BaseCommand {
|
public class ServiceLogsCommand extends BaseCommand {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceLogsCommand.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceLogsCommand.class);
|
||||||
private static final String LOG_FILE_NAME = "barn.log";
|
private static final String LOG_FILE_NAME = "barn.log";
|
||||||
|
|
||||||
@Option(names = {"--follow", "-f"}, description = "Follow log output")
|
@Option(names = {"--follow", "-f"}, description = "Follow log output")
|
||||||
|
|||||||
@@ -3,14 +3,13 @@ package com.samsonmedia.barn.cli;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||||
import com.samsonmedia.barn.ipc.IpcClient;
|
import com.samsonmedia.barn.ipc.IpcClient;
|
||||||
import com.samsonmedia.barn.ipc.IpcException;
|
import com.samsonmedia.barn.ipc.IpcException;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
|
|
||||||
import picocli.CommandLine.Command;
|
import picocli.CommandLine.Command;
|
||||||
import picocli.CommandLine.Option;
|
import picocli.CommandLine.Option;
|
||||||
@@ -25,7 +24,7 @@ import picocli.CommandLine.Option;
|
|||||||
)
|
)
|
||||||
public class ServiceReloadCommand extends BaseCommand {
|
public class ServiceReloadCommand extends BaseCommand {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceReloadCommand.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceReloadCommand.class);
|
||||||
|
|
||||||
@Option(names = {"--barn-dir"}, description = "Barn data directory", hidden = true)
|
@Option(names = {"--barn-dir"}, description = "Barn data directory", hidden = true)
|
||||||
private Path barnDir;
|
private Path barnDir;
|
||||||
@@ -49,7 +48,7 @@ public class ServiceReloadCommand extends BaseCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try (IpcClient client = new IpcClient(socketPath)) {
|
try (IpcClient client = new IpcClient(socketPath)) {
|
||||||
String result = client.send("reload", null, String.class);
|
client.send("reload", null, String.class);
|
||||||
getOut().println("Configuration reloaded");
|
getOut().println("Configuration reloaded");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
@@ -75,7 +74,7 @@ public class ServiceReloadCommand extends BaseCommand {
|
|||||||
long pid = Long.parseLong(pidStr);
|
long pid = Long.parseLong(pidStr);
|
||||||
|
|
||||||
// On Unix, we can send SIGHUP. On Windows, this won't work.
|
// On Unix, we can send SIGHUP. On Windows, this won't work.
|
||||||
String os = System.getProperty("os.name").toLowerCase();
|
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
|
||||||
if (os.contains("windows")) {
|
if (os.contains("windows")) {
|
||||||
outputError("Reload via signal not supported on Windows. IPC socket required.");
|
outputError("Reload via signal not supported on Windows. IPC socket required.");
|
||||||
return EXIT_ERROR;
|
return EXIT_ERROR;
|
||||||
|
|||||||
@@ -5,11 +5,9 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||||
import com.samsonmedia.barn.execution.ProcessUtils;
|
import com.samsonmedia.barn.execution.ProcessUtils;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
|
|
||||||
import picocli.CommandLine.Command;
|
import picocli.CommandLine.Command;
|
||||||
import picocli.CommandLine.Option;
|
import picocli.CommandLine.Option;
|
||||||
@@ -24,7 +22,7 @@ import picocli.CommandLine.Option;
|
|||||||
)
|
)
|
||||||
public class ServiceRestartCommand extends BaseCommand {
|
public class ServiceRestartCommand extends BaseCommand {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceRestartCommand.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceRestartCommand.class);
|
||||||
private static final long DEFAULT_WAIT_SECONDS = 30;
|
private static final long DEFAULT_WAIT_SECONDS = 30;
|
||||||
|
|
||||||
@Option(names = {"--force", "-f"}, description = "Force immediate restart")
|
@Option(names = {"--force", "-f"}, description = "Force immediate restart")
|
||||||
|
|||||||
@@ -5,12 +5,10 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.Config;
|
import com.samsonmedia.barn.config.Config;
|
||||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||||
import com.samsonmedia.barn.config.ConfigLoader;
|
import com.samsonmedia.barn.config.ConfigLoader;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.service.BarnService;
|
import com.samsonmedia.barn.service.BarnService;
|
||||||
|
|
||||||
import picocli.CommandLine.Command;
|
import picocli.CommandLine.Command;
|
||||||
@@ -26,7 +24,7 @@ import picocli.CommandLine.Option;
|
|||||||
)
|
)
|
||||||
public class ServiceStartCommand extends BaseCommand {
|
public class ServiceStartCommand extends BaseCommand {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceStartCommand.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceStartCommand.class);
|
||||||
|
|
||||||
@Option(names = {"--foreground", "-f"}, description = "Run in foreground (don't daemonize)")
|
@Option(names = {"--foreground", "-f"}, description = "Run in foreground (don't daemonize)")
|
||||||
private boolean foreground;
|
private boolean foreground;
|
||||||
|
|||||||
@@ -11,14 +11,12 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||||
import com.samsonmedia.barn.config.OperatingSystem;
|
import com.samsonmedia.barn.config.OperatingSystem;
|
||||||
import com.samsonmedia.barn.ipc.IpcClient;
|
import com.samsonmedia.barn.ipc.IpcClient;
|
||||||
import com.samsonmedia.barn.ipc.IpcException;
|
import com.samsonmedia.barn.ipc.IpcException;
|
||||||
import com.samsonmedia.barn.jobs.JobRepository;
|
import com.samsonmedia.barn.jobs.JobRepository;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.platform.linux.SystemdManager;
|
import com.samsonmedia.barn.platform.linux.SystemdManager;
|
||||||
import com.samsonmedia.barn.platform.macos.LaunchdManager;
|
import com.samsonmedia.barn.platform.macos.LaunchdManager;
|
||||||
import com.samsonmedia.barn.platform.windows.WindowsServiceManager;
|
import com.samsonmedia.barn.platform.windows.WindowsServiceManager;
|
||||||
@@ -38,7 +36,7 @@ import picocli.CommandLine.Option;
|
|||||||
)
|
)
|
||||||
public class ServiceStatusCommand extends BaseCommand {
|
public class ServiceStatusCommand extends BaseCommand {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceStatusCommand.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceStatusCommand.class);
|
||||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
|
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
|
||||||
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
@@ -155,8 +153,7 @@ public class ServiceStatusCommand extends BaseCommand {
|
|||||||
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case HUMAN -> outputHumanFormat(status);
|
case HUMAN -> outputHumanFormat(status);
|
||||||
case JSON -> output(status.toMap());
|
case JSON, XML -> output(status.toMap());
|
||||||
case XML -> output(status.toMap());
|
|
||||||
default -> outputHumanFormat(status);
|
default -> outputHumanFormat(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,9 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||||
import com.samsonmedia.barn.execution.ProcessUtils;
|
import com.samsonmedia.barn.execution.ProcessUtils;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
|
|
||||||
import picocli.CommandLine.Command;
|
import picocli.CommandLine.Command;
|
||||||
import picocli.CommandLine.Option;
|
import picocli.CommandLine.Option;
|
||||||
@@ -24,7 +22,7 @@ import picocli.CommandLine.Option;
|
|||||||
)
|
)
|
||||||
public class ServiceStopCommand extends BaseCommand {
|
public class ServiceStopCommand extends BaseCommand {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceStopCommand.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceStopCommand.class);
|
||||||
private static final long DEFAULT_WAIT_SECONDS = 30;
|
private static final long DEFAULT_WAIT_SECONDS = 30;
|
||||||
|
|
||||||
@Option(names = {"--force", "-f"}, description = "Force immediate stop (SIGKILL)")
|
@Option(names = {"--force", "-f"}, description = "Force immediate stop (SIGKILL)")
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package com.samsonmedia.barn.cli;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.OperatingSystem;
|
import com.samsonmedia.barn.config.OperatingSystem;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.platform.linux.SystemdManager;
|
import com.samsonmedia.barn.platform.linux.SystemdManager;
|
||||||
import com.samsonmedia.barn.platform.macos.LaunchdManager;
|
import com.samsonmedia.barn.platform.macos.LaunchdManager;
|
||||||
import com.samsonmedia.barn.platform.windows.WindowsServiceManager;
|
import com.samsonmedia.barn.platform.windows.WindowsServiceManager;
|
||||||
@@ -31,7 +29,7 @@ import picocli.CommandLine.Option;
|
|||||||
)
|
)
|
||||||
public class ServiceUninstallCommand extends BaseCommand {
|
public class ServiceUninstallCommand extends BaseCommand {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ServiceUninstallCommand.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(ServiceUninstallCommand.class);
|
||||||
|
|
||||||
@Option(names = {"--user"}, description = "Uninstall user service instead of system-wide")
|
@Option(names = {"--user"}, description = "Uninstall user service instead of system-wide")
|
||||||
private boolean userService;
|
private boolean userService;
|
||||||
|
|||||||
@@ -8,12 +8,10 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
@@ -23,6 +21,7 @@ import com.samsonmedia.barn.ipc.IpcClient;
|
|||||||
import com.samsonmedia.barn.ipc.IpcException;
|
import com.samsonmedia.barn.ipc.IpcException;
|
||||||
import com.samsonmedia.barn.jobs.Job;
|
import com.samsonmedia.barn.jobs.Job;
|
||||||
import com.samsonmedia.barn.jobs.JobRepository;
|
import com.samsonmedia.barn.jobs.JobRepository;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.state.BarnDirectories;
|
import com.samsonmedia.barn.state.BarnDirectories;
|
||||||
import com.samsonmedia.barn.state.JobState;
|
import com.samsonmedia.barn.state.JobState;
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ import picocli.CommandLine.Option;
|
|||||||
)
|
)
|
||||||
public class StatusCommand extends BaseCommand {
|
public class StatusCommand extends BaseCommand {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(StatusCommand.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(StatusCommand.class);
|
||||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
|
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
|
||||||
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
@@ -203,7 +202,7 @@ public class StatusCommand extends BaseCommand {
|
|||||||
for (Job job : jobs) {
|
for (Job job : jobs) {
|
||||||
sb.append(String.format("%-" + idWidth + "s %-9s %-" + tagWidth + "s %-19s %-4s %-8s%n",
|
sb.append(String.format("%-" + idWidth + "s %-9s %-" + tagWidth + "s %-19s %-4s %-8s%n",
|
||||||
job.id(),
|
job.id(),
|
||||||
job.state().toString().toLowerCase(),
|
job.state().toString().toLowerCase(Locale.ROOT),
|
||||||
job.tag() != null ? job.tag() : "-",
|
job.tag() != null ? job.tag() : "-",
|
||||||
formatTimestamp(job.createdAt()),
|
formatTimestamp(job.createdAt()),
|
||||||
job.exitCode() != null ? job.exitCode().toString() : "-",
|
job.exitCode() != null ? job.exitCode().toString() : "-",
|
||||||
@@ -262,7 +261,7 @@ public class StatusCommand extends BaseCommand {
|
|||||||
if (!first) {
|
if (!first) {
|
||||||
summary.append(", ");
|
summary.append(", ");
|
||||||
}
|
}
|
||||||
summary.append(count).append(" ").append(s.toString().toLowerCase());
|
summary.append(count).append(" ").append(s.toString().toLowerCase(Locale.ROOT));
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -280,7 +279,7 @@ public class StatusCommand extends BaseCommand {
|
|||||||
summary.put("total", jobs.size());
|
summary.put("total", jobs.size());
|
||||||
|
|
||||||
for (JobState s : JobState.values()) {
|
for (JobState s : JobState.values()) {
|
||||||
summary.put(s.toString().toLowerCase(), counts.getOrDefault(s, 0L));
|
summary.put(s.toString().toLowerCase(Locale.ROOT), counts.getOrDefault(s, 0L));
|
||||||
}
|
}
|
||||||
|
|
||||||
return summary;
|
return summary;
|
||||||
|
|||||||
@@ -13,14 +13,12 @@ import java.util.Optional;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||||
import com.samsonmedia.barn.ipc.IpcClient;
|
import com.samsonmedia.barn.ipc.IpcClient;
|
||||||
import com.samsonmedia.barn.ipc.IpcException;
|
import com.samsonmedia.barn.ipc.IpcException;
|
||||||
import com.samsonmedia.barn.jobs.Job;
|
import com.samsonmedia.barn.jobs.Job;
|
||||||
import com.samsonmedia.barn.jobs.JobRepository;
|
import com.samsonmedia.barn.jobs.JobRepository;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.monitoring.UsageLogger;
|
import com.samsonmedia.barn.monitoring.UsageLogger;
|
||||||
import com.samsonmedia.barn.monitoring.UsageRecord;
|
import com.samsonmedia.barn.monitoring.UsageRecord;
|
||||||
import com.samsonmedia.barn.state.BarnDirectories;
|
import com.samsonmedia.barn.state.BarnDirectories;
|
||||||
@@ -39,7 +37,7 @@ import picocli.CommandLine.Parameters;
|
|||||||
)
|
)
|
||||||
public class UsageCommand extends BaseCommand {
|
public class UsageCommand extends BaseCommand {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(UsageCommand.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(UsageCommand.class);
|
||||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
|
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
|
||||||
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.samsonmedia.barn.cli;
|
|||||||
import java.lang.reflect.RecordComponent;
|
import java.lang.reflect.RecordComponent;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.samsonmedia.barn.jobs.Job;
|
import com.samsonmedia.barn.jobs.Job;
|
||||||
@@ -92,7 +93,7 @@ public class XmlFormatter implements OutputFormatter {
|
|||||||
|
|
||||||
sb.append(indent).append("<job>\n");
|
sb.append(indent).append("<job>\n");
|
||||||
sb.append(childIndent).append("<id>").append(escapeXml(job.id())).append("</id>\n");
|
sb.append(childIndent).append("<id>").append(escapeXml(job.id())).append("</id>\n");
|
||||||
sb.append(childIndent).append("<state>").append(job.state().toString().toLowerCase())
|
sb.append(childIndent).append("<state>").append(job.state().toString().toLowerCase(Locale.ROOT))
|
||||||
.append("</state>\n");
|
.append("</state>\n");
|
||||||
|
|
||||||
// Command as nested elements
|
// Command as nested elements
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import java.nio.file.Path;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads and validates Barn configuration from files and environment variables.
|
* Loads and validates Barn configuration from files and environment variables.
|
||||||
@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public final class ConfigLoader {
|
public final class ConfigLoader {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ConfigLoader.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(ConfigLoader.class);
|
||||||
private static final String ENV_PREFIX = "BARN_";
|
private static final String ENV_PREFIX = "BARN_";
|
||||||
|
|
||||||
private final Map<String, String> environment;
|
private final Map<String, String> environment;
|
||||||
@@ -159,8 +159,8 @@ public final class ConfigLoader {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String section = remainder.substring(0, underscoreIndex).toLowerCase();
|
String section = remainder.substring(0, underscoreIndex).toLowerCase(Locale.ROOT);
|
||||||
String configKey = remainder.substring(underscoreIndex + 1).toLowerCase();
|
String configKey = remainder.substring(underscoreIndex + 1).toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
LOG.debug("Applying environment override: {}={}", key, value);
|
LOG.debug("Applying environment override: {}={}", key, value);
|
||||||
data.computeIfAbsent(section, k -> new HashMap<>())
|
data.computeIfAbsent(section, k -> new HashMap<>())
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.samsonmedia.barn.config;
|
package com.samsonmedia.barn.config;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log level for the Barn service.
|
* Log level for the Barn service.
|
||||||
*/
|
*/
|
||||||
@@ -21,7 +23,7 @@ public enum LogLevel {
|
|||||||
throw new IllegalArgumentException("Log level cannot be null or blank");
|
throw new IllegalArgumentException("Log level cannot be null or blank");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return valueOf(value.trim().toUpperCase());
|
return valueOf(value.trim().toUpperCase(Locale.ROOT));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Invalid log level: '" + value + "'. Valid values are: debug, info, warn, error");
|
"Invalid log level: '" + value + "'. Valid values are: debug, info, warn, error");
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.samsonmedia.barn.config;
|
package com.samsonmedia.barn.config;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the operating system Barn is running on.
|
* Represents the operating system Barn is running on.
|
||||||
*/
|
*/
|
||||||
@@ -23,7 +25,7 @@ public enum OperatingSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static OperatingSystem detect() {
|
private static OperatingSystem detect() {
|
||||||
String osName = System.getProperty("os.name", "").toLowerCase();
|
String osName = System.getProperty("os.name", "").toLowerCase(Locale.ROOT);
|
||||||
if (osName.contains("win")) {
|
if (osName.contains("win")) {
|
||||||
return WINDOWS;
|
return WINDOWS;
|
||||||
} else if (osName.contains("mac") || osName.contains("darwin")) {
|
} else if (osName.contains("mac") || osName.contains("darwin")) {
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.Config;
|
import com.samsonmedia.barn.config.Config;
|
||||||
import com.samsonmedia.barn.jobs.Job;
|
import com.samsonmedia.barn.jobs.Job;
|
||||||
import com.samsonmedia.barn.jobs.JobRepository;
|
import com.samsonmedia.barn.jobs.JobRepository;
|
||||||
import com.samsonmedia.barn.jobs.RetryCalculator;
|
import com.samsonmedia.barn.jobs.RetryCalculator;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.state.BarnDirectories;
|
import com.samsonmedia.barn.state.BarnDirectories;
|
||||||
import com.samsonmedia.barn.state.JobState;
|
import com.samsonmedia.barn.state.JobState;
|
||||||
|
|
||||||
@@ -31,7 +29,7 @@ import com.samsonmedia.barn.state.JobState;
|
|||||||
*/
|
*/
|
||||||
public class CrashRecovery {
|
public class CrashRecovery {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(CrashRecovery.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(CrashRecovery.class);
|
||||||
private static final String KILLED_ERROR = "Process killed - daemon restarted";
|
private static final String KILLED_ERROR = "Process killed - daemon restarted";
|
||||||
|
|
||||||
private final JobRepository repository;
|
private final JobRepository repository;
|
||||||
|
|||||||
@@ -7,13 +7,11 @@ import java.time.Instant;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.JobsConfig;
|
import com.samsonmedia.barn.config.JobsConfig;
|
||||||
import com.samsonmedia.barn.jobs.Job;
|
import com.samsonmedia.barn.jobs.Job;
|
||||||
import com.samsonmedia.barn.jobs.JobRepository;
|
import com.samsonmedia.barn.jobs.JobRepository;
|
||||||
import com.samsonmedia.barn.jobs.RetryCalculator;
|
import com.samsonmedia.barn.jobs.RetryCalculator;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.monitoring.UsageMonitor;
|
import com.samsonmedia.barn.monitoring.UsageMonitor;
|
||||||
import com.samsonmedia.barn.state.BarnDirectories;
|
import com.samsonmedia.barn.state.BarnDirectories;
|
||||||
|
|
||||||
@@ -32,7 +30,7 @@ import com.samsonmedia.barn.state.BarnDirectories;
|
|||||||
*/
|
*/
|
||||||
public class JobRunner {
|
public class JobRunner {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(JobRunner.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(JobRunner.class);
|
||||||
private static final String STDOUT_LOG = "stdout.log";
|
private static final String STDOUT_LOG = "stdout.log";
|
||||||
private static final String STDERR_LOG = "stderr.log";
|
private static final String STDERR_LOG = "stderr.log";
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,10 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.Config;
|
import com.samsonmedia.barn.config.Config;
|
||||||
import com.samsonmedia.barn.jobs.Job;
|
import com.samsonmedia.barn.jobs.Job;
|
||||||
import com.samsonmedia.barn.jobs.JobRepository;
|
import com.samsonmedia.barn.jobs.JobRepository;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.state.BarnDirectories;
|
import com.samsonmedia.barn.state.BarnDirectories;
|
||||||
import com.samsonmedia.barn.state.JobState;
|
import com.samsonmedia.barn.state.JobState;
|
||||||
|
|
||||||
@@ -31,7 +29,7 @@ import com.samsonmedia.barn.state.JobState;
|
|||||||
*/
|
*/
|
||||||
public class JobScheduler {
|
public class JobScheduler {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(JobScheduler.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(JobScheduler.class);
|
||||||
private static final Duration DEFAULT_POLL_INTERVAL = Duration.ofSeconds(1);
|
private static final Duration DEFAULT_POLL_INTERVAL = Duration.ofSeconds(1);
|
||||||
private static final Duration DEFAULT_SHUTDOWN_TIMEOUT = Duration.ofMinutes(5);
|
private static final Duration DEFAULT_SHUTDOWN_TIMEOUT = Duration.ofMinutes(5);
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes processes and captures their output.
|
* Executes processes and captures their output.
|
||||||
@@ -21,7 +20,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class ProcessExecutor {
|
public class ProcessExecutor {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ProcessExecutor.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(ProcessExecutor.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a command and returns the process.
|
* Executes a command and returns the process.
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitors a running process and emits events.
|
* Monitors a running process and emits events.
|
||||||
@@ -20,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class ProcessMonitor {
|
public class ProcessMonitor {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ProcessMonitor.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(ProcessMonitor.class);
|
||||||
private static final Duration DEFAULT_HEARTBEAT_INTERVAL = Duration.ofSeconds(10);
|
private static final Duration DEFAULT_HEARTBEAT_INTERVAL = Duration.ofSeconds(10);
|
||||||
|
|
||||||
private final Duration heartbeatInterval;
|
private final Duration heartbeatInterval;
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ package com.samsonmedia.barn.execution;
|
|||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cross-platform process utilities.
|
* Cross-platform process utilities.
|
||||||
@@ -13,7 +12,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public final class ProcessUtils {
|
public final class ProcessUtils {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ProcessUtils.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(ProcessUtils.class);
|
||||||
|
|
||||||
private ProcessUtils() {
|
private ProcessUtils() {
|
||||||
// Utility class - prevent instantiation
|
// Utility class - prevent instantiation
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import java.nio.file.StandardOpenOption;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lock to ensure only one scheduler runs at a time.
|
* Lock to ensure only one scheduler runs at a time.
|
||||||
@@ -21,7 +20,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public final class SchedulerLock implements Closeable {
|
public final class SchedulerLock implements Closeable {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(SchedulerLock.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(SchedulerLock.class);
|
||||||
|
|
||||||
private final Path lockFile;
|
private final Path lockFile;
|
||||||
private final FileChannel channel;
|
private final FileChannel channel;
|
||||||
|
|||||||
@@ -12,14 +12,13 @@ import java.nio.channels.SocketChannel;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IPC client for communicating with the barn service.
|
* IPC client for communicating with the barn service.
|
||||||
@@ -29,7 +28,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
|||||||
*/
|
*/
|
||||||
public class IpcClient implements AutoCloseable {
|
public class IpcClient implements AutoCloseable {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(IpcClient.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(IpcClient.class);
|
||||||
private static final int DEFAULT_TIMEOUT_MS = 30000;
|
private static final int DEFAULT_TIMEOUT_MS = 30000;
|
||||||
|
|
||||||
private final Path socketPath;
|
private final Path socketPath;
|
||||||
@@ -177,7 +176,7 @@ public class IpcClient implements AutoCloseable {
|
|||||||
* @return the default socket path
|
* @return the default socket path
|
||||||
*/
|
*/
|
||||||
public static Path getDefaultSocketPath() {
|
public static Path getDefaultSocketPath() {
|
||||||
String os = System.getProperty("os.name").toLowerCase();
|
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
|
||||||
if (os.contains("win")) {
|
if (os.contains("win")) {
|
||||||
// Windows - use temp directory (named pipes require JNI)
|
// Windows - use temp directory (named pipes require JNI)
|
||||||
return Path.of(System.getProperty("java.io.tmpdir"), "barn", "barn.sock");
|
return Path.of(System.getProperty("java.io.tmpdir"), "barn", "barn.sock");
|
||||||
|
|||||||
@@ -18,12 +18,10 @@ import java.util.concurrent.ExecutorService;
|
|||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IPC server for receiving requests from CLI clients.
|
* IPC server for receiving requests from CLI clients.
|
||||||
@@ -32,7 +30,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
|||||||
*/
|
*/
|
||||||
public class IpcServer {
|
public class IpcServer {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(IpcServer.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(IpcServer.class);
|
||||||
|
|
||||||
private final Path socketPath;
|
private final Path socketPath;
|
||||||
private final RequestHandler handler;
|
private final RequestHandler handler;
|
||||||
|
|||||||
@@ -10,13 +10,11 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import com.samsonmedia.barn.config.JobsConfig;
|
import com.samsonmedia.barn.config.JobsConfig;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.state.AtomicFiles;
|
import com.samsonmedia.barn.state.AtomicFiles;
|
||||||
import com.samsonmedia.barn.state.BarnDirectories;
|
import com.samsonmedia.barn.state.BarnDirectories;
|
||||||
import com.samsonmedia.barn.state.JobState;
|
import com.samsonmedia.barn.state.JobState;
|
||||||
@@ -30,7 +28,7 @@ import com.samsonmedia.barn.state.StateFiles;
|
|||||||
*/
|
*/
|
||||||
public class JobRepository {
|
public class JobRepository {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(JobRepository.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(JobRepository.class);
|
||||||
private static final String MANIFEST_FILE = "manifest.json";
|
private static final String MANIFEST_FILE = "manifest.json";
|
||||||
|
|
||||||
private final BarnDirectories dirs;
|
private final BarnDirectories dirs;
|
||||||
|
|||||||
@@ -0,0 +1,170 @@
|
|||||||
|
package com.samsonmedia.barn.logging;
|
||||||
|
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple logger for Barn that can be globally disabled for CLI commands.
|
||||||
|
*
|
||||||
|
* <p>CLI commands should not produce any log output to avoid breaking
|
||||||
|
* JSON/XML output. The service enables logging on startup.
|
||||||
|
*/
|
||||||
|
public final class BarnLogger {
|
||||||
|
|
||||||
|
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
||||||
|
private static volatile boolean enabled = false;
|
||||||
|
private static volatile Level level = Level.INFO;
|
||||||
|
private static volatile PrintStream output = System.err;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log levels supported by BarnLogger.
|
||||||
|
*/
|
||||||
|
public enum Level {
|
||||||
|
DEBUG(0), INFO(1), WARN(2), ERROR(3), OFF(4);
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
|
||||||
|
Level(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isEnabled(Level threshold) {
|
||||||
|
return this.value >= threshold.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
private BarnLogger(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BarnLogger getLogger(Class<?> clazz) {
|
||||||
|
return new BarnLogger(clazz.getSimpleName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BarnLogger getLogger(String name) {
|
||||||
|
return new BarnLogger(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables logging globally. Called by the service on startup.
|
||||||
|
*/
|
||||||
|
public static void enable() {
|
||||||
|
enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables logging globally. Default state for CLI commands.
|
||||||
|
*/
|
||||||
|
public static void disable() {
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the global log level.
|
||||||
|
*/
|
||||||
|
public static void setLevel(Level newLevel) {
|
||||||
|
level = newLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current global log level.
|
||||||
|
*
|
||||||
|
* @return the current log level
|
||||||
|
*/
|
||||||
|
public static Level getLevel() {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the output stream for logs.
|
||||||
|
*/
|
||||||
|
public static void setOutput(PrintStream stream) {
|
||||||
|
output = stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a trace-level message. Mapped to DEBUG level.
|
||||||
|
*/
|
||||||
|
public void trace(String message, Object... args) {
|
||||||
|
log(Level.DEBUG, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(String message, Object... args) {
|
||||||
|
log(Level.DEBUG, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info(String message, Object... args) {
|
||||||
|
log(Level.INFO, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn(String message, Object... args) {
|
||||||
|
log(Level.WARN, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error(String message, Object... args) {
|
||||||
|
log(Level.ERROR, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs an error message with a throwable.
|
||||||
|
*
|
||||||
|
* @param message the message to log
|
||||||
|
* @param t the throwable to log
|
||||||
|
*/
|
||||||
|
public void error(String message, Throwable t) {
|
||||||
|
if (!enabled || !Level.ERROR.isEnabled(level)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String timestamp = LocalDateTime.now().format(FORMATTER);
|
||||||
|
output.println(String.format("%s [%s] ERROR %s - %s",
|
||||||
|
timestamp, Thread.currentThread().getName(), name, message));
|
||||||
|
if (t != null) {
|
||||||
|
t.printStackTrace(output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDebugEnabled() {
|
||||||
|
return enabled && Level.DEBUG.isEnabled(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInfoEnabled() {
|
||||||
|
return enabled && Level.INFO.isEnabled(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void log(Level msgLevel, String message, Object... args) {
|
||||||
|
if (!enabled || !msgLevel.isEnabled(level)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String timestamp = LocalDateTime.now().format(FORMATTER);
|
||||||
|
String formattedMessage = formatMessage(message, args);
|
||||||
|
output.println(String.format("%s [%s] %-5s %s - %s",
|
||||||
|
timestamp, Thread.currentThread().getName(), msgLevel, name, formattedMessage));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatMessage(String message, Object... args) {
|
||||||
|
if (args == null || args.length == 0) {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
// Simple {} placeholder replacement like SLF4J
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
int argIndex = 0;
|
||||||
|
int i = 0;
|
||||||
|
while (i < message.length()) {
|
||||||
|
if (i < message.length() - 1 && message.charAt(i) == '{' && message.charAt(i + 1) == '}') {
|
||||||
|
if (argIndex < args.length) {
|
||||||
|
sb.append(args[argIndex++]);
|
||||||
|
} else {
|
||||||
|
sb.append("{}");
|
||||||
|
}
|
||||||
|
i += 2;
|
||||||
|
} else {
|
||||||
|
sb.append(message.charAt(i));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,9 +4,6 @@ import java.time.Duration;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.jobs.Job;
|
import com.samsonmedia.barn.jobs.Job;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,7 +13,7 @@ import com.samsonmedia.barn.jobs.Job;
|
|||||||
*/
|
*/
|
||||||
public final class JobLogEvents {
|
public final class JobLogEvents {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(JobLogEvents.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(JobLogEvents.class);
|
||||||
|
|
||||||
private JobLogEvents() {
|
private JobLogEvents() {
|
||||||
// Utility class
|
// Utility class
|
||||||
|
|||||||
@@ -5,14 +5,8 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.LogLevel;
|
import com.samsonmedia.barn.config.LogLevel;
|
||||||
|
|
||||||
import ch.qos.logback.classic.Level;
|
|
||||||
import ch.qos.logback.classic.Logger;
|
|
||||||
import ch.qos.logback.classic.LoggerContext;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration utilities for the logging system.
|
* Configuration utilities for the logging system.
|
||||||
*
|
*
|
||||||
@@ -25,17 +19,15 @@ public final class LoggingConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the root log level at runtime.
|
* Sets the root log level at runtime and enables logging.
|
||||||
*
|
*
|
||||||
* @param level the log level to set
|
* @param level the log level to set
|
||||||
* @throws NullPointerException if level is null
|
* @throws NullPointerException if level is null
|
||||||
*/
|
*/
|
||||||
public static void setLogLevel(LogLevel level) {
|
public static void setLogLevel(LogLevel level) {
|
||||||
Objects.requireNonNull(level, "level must not be null");
|
Objects.requireNonNull(level, "level must not be null");
|
||||||
|
BarnLogger.enable();
|
||||||
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
|
BarnLogger.setLevel(toBarnLoggerLevel(level));
|
||||||
Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);
|
|
||||||
rootLogger.setLevel(toLogbackLevel(level));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,9 +36,7 @@ public final class LoggingConfig {
|
|||||||
* @return the current log level
|
* @return the current log level
|
||||||
*/
|
*/
|
||||||
public static LogLevel getLogLevel() {
|
public static LogLevel getLogLevel() {
|
||||||
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
|
return fromBarnLoggerLevel(BarnLogger.getLevel());
|
||||||
Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);
|
|
||||||
return fromLogbackLevel(rootLogger.getLevel());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,28 +69,21 @@ public final class LoggingConfig {
|
|||||||
return Path.of(System.getProperty("java.io.tmpdir"), "barn", "logs");
|
return Path.of(System.getProperty("java.io.tmpdir"), "barn", "logs");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Level toLogbackLevel(LogLevel level) {
|
private static BarnLogger.Level toBarnLoggerLevel(LogLevel level) {
|
||||||
return switch (level) {
|
return switch (level) {
|
||||||
case DEBUG -> Level.DEBUG;
|
case DEBUG -> BarnLogger.Level.DEBUG;
|
||||||
case INFO -> Level.INFO;
|
case INFO -> BarnLogger.Level.INFO;
|
||||||
case WARN -> Level.WARN;
|
case WARN -> BarnLogger.Level.WARN;
|
||||||
case ERROR -> Level.ERROR;
|
case ERROR -> BarnLogger.Level.ERROR;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LogLevel fromLogbackLevel(Level level) {
|
private static LogLevel fromBarnLoggerLevel(BarnLogger.Level level) {
|
||||||
if (level == null || level.equals(Level.INFO)) {
|
return switch (level) {
|
||||||
return LogLevel.INFO;
|
case DEBUG -> LogLevel.DEBUG;
|
||||||
}
|
case INFO -> LogLevel.INFO;
|
||||||
if (level.equals(Level.DEBUG) || level.equals(Level.TRACE)) {
|
case WARN -> LogLevel.WARN;
|
||||||
return LogLevel.DEBUG;
|
case ERROR, OFF -> LogLevel.ERROR;
|
||||||
}
|
};
|
||||||
if (level.equals(Level.WARN)) {
|
|
||||||
return LogLevel.WARN;
|
|
||||||
}
|
|
||||||
if (level.equals(Level.ERROR) || level.equals(Level.OFF)) {
|
|
||||||
return LogLevel.ERROR;
|
|
||||||
}
|
|
||||||
return LogLevel.INFO;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,13 +6,13 @@ import java.io.InputStreamReader;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collects resource usage metrics for a process.
|
* Collects resource usage metrics for a process.
|
||||||
@@ -21,7 +21,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class UsageCollector {
|
public class UsageCollector {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(UsageCollector.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(UsageCollector.class);
|
||||||
private static final int COMMAND_TIMEOUT_SECONDS = 5;
|
private static final int COMMAND_TIMEOUT_SECONDS = 5;
|
||||||
|
|
||||||
private final boolean isWindows;
|
private final boolean isWindows;
|
||||||
@@ -32,7 +32,7 @@ public class UsageCollector {
|
|||||||
* Creates a new UsageCollector.
|
* Creates a new UsageCollector.
|
||||||
*/
|
*/
|
||||||
public UsageCollector() {
|
public UsageCollector() {
|
||||||
String os = System.getProperty("os.name").toLowerCase();
|
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
|
||||||
this.isWindows = os.contains("win");
|
this.isWindows = os.contains("win");
|
||||||
this.isMac = os.contains("mac");
|
this.isMac = os.contains("mac");
|
||||||
this.isLinux = os.contains("linux");
|
this.isLinux = os.contains("linux");
|
||||||
@@ -254,7 +254,8 @@ public class UsageCollector {
|
|||||||
Process process = pb.start();
|
Process process = pb.start();
|
||||||
|
|
||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
|
try (BufferedReader reader = new BufferedReader(
|
||||||
|
new InputStreamReader(process.getInputStream(), java.nio.charset.StandardCharsets.UTF_8))) {
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
output.append(line).append("\n");
|
output.append(line).append("\n");
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes usage records to a CSV file.
|
* Writes usage records to a CSV file.
|
||||||
@@ -18,7 +17,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class UsageLogger implements Closeable {
|
public class UsageLogger implements Closeable {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(UsageLogger.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(UsageLogger.class);
|
||||||
|
|
||||||
/** Default filename for usage logs. */
|
/** Default filename for usage logs. */
|
||||||
public static final String USAGE_LOG_FILENAME = "usage.csv";
|
public static final String USAGE_LOG_FILENAME = "usage.csv";
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import java.util.concurrent.ScheduledFuture;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitors resource usage for a process over time.
|
* Monitors resource usage for a process over time.
|
||||||
@@ -20,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class UsageMonitor implements Closeable {
|
public class UsageMonitor implements Closeable {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(UsageMonitor.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(UsageMonitor.class);
|
||||||
|
|
||||||
/** Default collection interval in seconds. */
|
/** Default collection interval in seconds. */
|
||||||
public static final int DEFAULT_INTERVAL_SECONDS = 5;
|
public static final int DEFAULT_INTERVAL_SECONDS = 5;
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages Linux systemd service operations.
|
* Manages Linux systemd service operations.
|
||||||
@@ -22,7 +21,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class SystemdManager {
|
public class SystemdManager {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(SystemdManager.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(SystemdManager.class);
|
||||||
private static final String SERVICE_NAME = "barn.service";
|
private static final String SERVICE_NAME = "barn.service";
|
||||||
private static final long COMMAND_TIMEOUT_SECONDS = 30;
|
private static final long COMMAND_TIMEOUT_SECONDS = 30;
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages macOS launchd service operations.
|
* Manages macOS launchd service operations.
|
||||||
@@ -20,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class LaunchdManager {
|
public class LaunchdManager {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(LaunchdManager.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(LaunchdManager.class);
|
||||||
private static final String LABEL = "com.samsonmedia.barn";
|
private static final String LABEL = "com.samsonmedia.barn";
|
||||||
private static final long COMMAND_TIMEOUT_SECONDS = 30;
|
private static final long COMMAND_TIMEOUT_SECONDS = 30;
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import java.io.InputStreamReader;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages Windows service operations using sc.exe.
|
* Manages Windows service operations using sc.exe.
|
||||||
@@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class WindowsServiceManager {
|
public class WindowsServiceManager {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(WindowsServiceManager.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(WindowsServiceManager.class);
|
||||||
private static final String SERVICE_NAME = "barn";
|
private static final String SERVICE_NAME = "barn";
|
||||||
private static final String DISPLAY_NAME = "Barn Job Daemon";
|
private static final String DISPLAY_NAME = "Barn Job Daemon";
|
||||||
private static final long COMMAND_TIMEOUT_SECONDS = 30;
|
private static final long COMMAND_TIMEOUT_SECONDS = 30;
|
||||||
@@ -70,7 +70,7 @@ public class WindowsServiceManager {
|
|||||||
* @return true if Windows services are supported
|
* @return true if Windows services are supported
|
||||||
*/
|
*/
|
||||||
public static boolean hasWindowsServices() {
|
public static boolean hasWindowsServices() {
|
||||||
String osName = System.getProperty("os.name", "").toLowerCase();
|
String osName = System.getProperty("os.name", "").toLowerCase(Locale.ROOT);
|
||||||
return osName.contains("windows");
|
return osName.contains("windows");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,11 @@ import java.io.IOException;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import com.samsonmedia.barn.config.Config;
|
import com.samsonmedia.barn.config.Config;
|
||||||
@@ -23,6 +21,8 @@ import com.samsonmedia.barn.ipc.IpcException;
|
|||||||
import com.samsonmedia.barn.ipc.IpcServer;
|
import com.samsonmedia.barn.ipc.IpcServer;
|
||||||
import com.samsonmedia.barn.jobs.Job;
|
import com.samsonmedia.barn.jobs.Job;
|
||||||
import com.samsonmedia.barn.jobs.JobRepository;
|
import com.samsonmedia.barn.jobs.JobRepository;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
|
import com.samsonmedia.barn.logging.LoggingConfig;
|
||||||
import com.samsonmedia.barn.state.BarnDirectories;
|
import com.samsonmedia.barn.state.BarnDirectories;
|
||||||
import com.samsonmedia.barn.state.JobState;
|
import com.samsonmedia.barn.state.JobState;
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ import com.samsonmedia.barn.state.JobState;
|
|||||||
*/
|
*/
|
||||||
public class BarnService {
|
public class BarnService {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(BarnService.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(BarnService.class);
|
||||||
|
|
||||||
private final Config config;
|
private final Config config;
|
||||||
private final BarnDirectories dirs;
|
private final BarnDirectories dirs;
|
||||||
@@ -87,6 +87,9 @@ public class BarnService {
|
|||||||
throw new IllegalStateException("Service already running");
|
throw new IllegalStateException("Service already running");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable logging for the service (CLI commands have logging OFF by default)
|
||||||
|
LoggingConfig.setLogLevel(config.service().logLevel());
|
||||||
|
|
||||||
LOG.info("Starting Barn service");
|
LOG.info("Starting Barn service");
|
||||||
|
|
||||||
// 1. Initialize directories
|
// 1. Initialize directories
|
||||||
@@ -263,7 +266,7 @@ public class BarnService {
|
|||||||
tag = (String) map.get("tag");
|
tag = (String) map.get("tag");
|
||||||
String stateStr = (String) map.get("state");
|
String stateStr = (String) map.get("state");
|
||||||
if (stateStr != null) {
|
if (stateStr != null) {
|
||||||
state = JobState.valueOf(stateStr.toUpperCase());
|
state = JobState.valueOf(stateStr.toUpperCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
limit = (Integer) map.get("limit");
|
limit = (Integer) map.get("limit");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,10 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.samsonmedia.barn.config.CleanupConfig;
|
import com.samsonmedia.barn.config.CleanupConfig;
|
||||||
import com.samsonmedia.barn.jobs.Job;
|
import com.samsonmedia.barn.jobs.Job;
|
||||||
import com.samsonmedia.barn.jobs.JobRepository;
|
import com.samsonmedia.barn.jobs.JobRepository;
|
||||||
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import com.samsonmedia.barn.state.JobState;
|
import com.samsonmedia.barn.state.JobState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +21,7 @@ import com.samsonmedia.barn.state.JobState;
|
|||||||
*/
|
*/
|
||||||
public class CleanupScheduler {
|
public class CleanupScheduler {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(CleanupScheduler.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(CleanupScheduler.class);
|
||||||
|
|
||||||
private final JobRepository repository;
|
private final JobRepository repository;
|
||||||
private final CleanupConfig config;
|
private final CleanupConfig config;
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import java.nio.file.StandardOpenOption;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import com.samsonmedia.barn.logging.BarnLogger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A file-based lock for coordinating access to resources.
|
* A file-based lock for coordinating access to resources.
|
||||||
@@ -20,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public final class FileLock implements AutoCloseable {
|
public final class FileLock implements AutoCloseable {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(FileLock.class);
|
private static final BarnLogger LOG = BarnLogger.getLogger(FileLock.class);
|
||||||
|
|
||||||
private final Path lockFile;
|
private final Path lockFile;
|
||||||
private final FileChannel channel;
|
private final FileChannel channel;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.samsonmedia.barn.state;
|
package com.samsonmedia.barn.state;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the current state of a job in its lifecycle.
|
* Represents the current state of a job in its lifecycle.
|
||||||
*/
|
*/
|
||||||
@@ -34,7 +36,7 @@ public enum JobState {
|
|||||||
throw new IllegalArgumentException("Job state cannot be null or blank");
|
throw new IllegalArgumentException("Job state cannot be null or blank");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return valueOf(value.trim().toUpperCase());
|
return valueOf(value.trim().toUpperCase(Locale.ROOT));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new IllegalArgumentException("Invalid job state: '" + value
|
throw new IllegalArgumentException("Invalid job state: '" + value
|
||||||
+ "'. Valid values are: queued, running, succeeded, failed, canceled, killed");
|
+ "'. Valid values are: queued, running, succeeded, failed, canceled, killed");
|
||||||
@@ -47,7 +49,7 @@ public enum JobState {
|
|||||||
* @return the state name in lowercase
|
* @return the state name in lowercase
|
||||||
*/
|
*/
|
||||||
public String toLowercase() {
|
public String toLowercase() {
|
||||||
return name().toLowerCase();
|
return name().toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.samsonmedia.barn.util;
|
package com.samsonmedia.barn.util;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ public final class DurationParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
long value = Long.parseLong(matcher.group(1));
|
long value = Long.parseLong(matcher.group(1));
|
||||||
String unit = matcher.group(2).toLowerCase();
|
String unit = matcher.group(2).toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
if (value <= 0) {
|
if (value <= 0) {
|
||||||
throw new IllegalArgumentException("Duration value must be positive: " + value);
|
throw new IllegalArgumentException("Duration value must be positive: " + value);
|
||||||
|
|||||||
+42
-168
@@ -1,187 +1,61 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "com.samsonmedia.barn.ipc.IpcMessage",
|
"name": "ch.qos.logback.core.status.NopStatusListener",
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$RunJob",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$GetStatus",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$GetJob",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$KillJob",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$CleanJobs",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$GetServiceStatus",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$Shutdown",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.ipc.IpcRequest$Reload",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.ipc.IpcResponse$Ok",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.ipc.IpcResponse$Error",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.jobs.Job",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.jobs.JobManifest",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.state.JobState",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.execution.ResourceUsage",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.config.Config",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.config.ServiceConfig",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.config.StorageConfig",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.config.JobsConfig",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "com.samsonmedia.barn.config.CleanupConfig",
|
|
||||||
"allDeclaredConstructors": true,
|
|
||||||
"allPublicConstructors": true,
|
|
||||||
"allDeclaredMethods": true,
|
|
||||||
"allPublicMethods": true,
|
|
||||||
"allDeclaredFields": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "java.util.LinkedHashMap",
|
|
||||||
"allDeclaredConstructors": true,
|
"allDeclaredConstructors": true,
|
||||||
"allPublicConstructors": true
|
"allPublicConstructors": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "java.util.HashMap",
|
"name": "ch.qos.logback.core.helpers.NOPAppender",
|
||||||
"allDeclaredConstructors": true,
|
"allDeclaredConstructors": true,
|
||||||
"allPublicConstructors": true
|
"allPublicConstructors": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "java.util.ArrayList",
|
"name": "ch.qos.logback.core.FileAppender",
|
||||||
"allDeclaredConstructors": true,
|
"allDeclaredConstructors": true,
|
||||||
"allPublicConstructors": true
|
"allPublicConstructors": true,
|
||||||
|
"allDeclaredMethods": true,
|
||||||
|
"allPublicMethods": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "java.util.ImmutableCollections$ListN",
|
"name": "ch.qos.logback.core.rolling.RollingFileAppender",
|
||||||
"allDeclaredConstructors": true,
|
"allDeclaredConstructors": true,
|
||||||
"allPublicConstructors": true
|
"allPublicConstructors": true,
|
||||||
|
"allDeclaredMethods": true,
|
||||||
|
"allPublicMethods": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "java.util.ImmutableCollections$List12",
|
"name": "ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy",
|
||||||
"allDeclaredConstructors": true,
|
"allDeclaredConstructors": true,
|
||||||
"allPublicConstructors": true
|
"allPublicConstructors": true,
|
||||||
|
"allDeclaredMethods": true,
|
||||||
|
"allPublicMethods": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ch.qos.logback.classic.encoder.PatternLayoutEncoder",
|
||||||
|
"allDeclaredConstructors": true,
|
||||||
|
"allPublicConstructors": true,
|
||||||
|
"allDeclaredMethods": true,
|
||||||
|
"allPublicMethods": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ch.qos.logback.core.ConsoleAppender",
|
||||||
|
"allDeclaredConstructors": true,
|
||||||
|
"allPublicConstructors": true,
|
||||||
|
"allDeclaredMethods": true,
|
||||||
|
"allPublicMethods": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ch.qos.logback.classic.PatternLayout",
|
||||||
|
"allDeclaredConstructors": true,
|
||||||
|
"allPublicConstructors": true,
|
||||||
|
"allDeclaredMethods": true,
|
||||||
|
"allPublicMethods": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "net.logstash.logback.encoder.LogstashEncoder",
|
||||||
|
"allDeclaredConstructors": true,
|
||||||
|
"allPublicConstructors": true,
|
||||||
|
"allDeclaredMethods": true,
|
||||||
|
"allPublicMethods": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"resources": {
|
||||||
|
"includes": [
|
||||||
|
{"pattern": "logback.xml"},
|
||||||
|
{"pattern": "META-INF/.*"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"bundles": []
|
||||||
|
}
|
||||||
@@ -1,44 +1,24 @@
|
|||||||
<configuration>
|
<configuration debug="false">
|
||||||
<!-- Suppress logback's internal status messages -->
|
<!-- Suppress ALL logback output including internal status -->
|
||||||
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
|
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
|
||||||
|
|
||||||
<!-- Console appender for development/foreground -->
|
<!-- NOP appender - discards all logs -->
|
||||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="NOP" class="ch.qos.logback.core.helpers.NOPAppender"/>
|
||||||
<encoder>
|
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- File appender for daemon mode -->
|
<!-- File appender for service logging (only used when service enables it) -->
|
||||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||||
<file>${BARN_LOG_DIR:-/tmp/barn/logs}/barn.log</file>
|
<file>/tmp/barn/logs/barn.log</file>
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
<append>true</append>
|
||||||
<fileNamePattern>${BARN_LOG_DIR:-/tmp/barn/logs}/barn.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
|
||||||
<maxFileSize>10MB</maxFileSize>
|
|
||||||
<maxHistory>7</maxHistory>
|
|
||||||
<totalSizeCap>100MB</totalSizeCap>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
<pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!-- JSON appender for structured logging -->
|
<!--
|
||||||
<appender name="JSON" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
Root logger OFF by default - CLI commands produce no log output.
|
||||||
<file>${BARN_LOG_DIR:-/tmp/barn/logs}/barn.json.log</file>
|
Service startup explicitly enables logging via LoggingConfig.
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
-->
|
||||||
<fileNamePattern>${BARN_LOG_DIR:-/tmp/barn/logs}/barn.json.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
<root level="OFF">
|
||||||
<maxFileSize>10MB</maxFileSize>
|
<appender-ref ref="NOP"/>
|
||||||
<maxHistory>7</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
|
|
||||||
<includeMdcKeyName>jobId</includeMdcKeyName>
|
|
||||||
<includeMdcKeyName>jobTag</includeMdcKeyName>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- Log to file only by default (CLI commands). Service foreground mode adds console programmatically -->
|
|
||||||
<root level="${BARN_LOG_LEVEL:-INFO}">
|
|
||||||
<appender-ref ref="FILE"/>
|
|
||||||
</root>
|
</root>
|
||||||
</configuration>
|
</configuration>
|
||||||
Reference in new issue
Block a user