Archived
Replace SLF4J with BarnLogger and update documentation
- Replace SLF4J/logback with custom BarnLogger across all source files - BarnLogger is disabled by default for CLI commands, enabled for service - Fixes #30: debug logs no longer break JSON/XML CLI output - Add SpotBugs exclusions for BarnLogger false positives - Update docs: remove .deb and AUR references (no longer applicable) - Update docs: add Windows setup.exe installation instructions - Update docs: clarify auto-update only works with Homebrew Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
41126eeed4
commit
d95ac32739
44 files changed
+466
-1227
No files matched your search
@@ -315,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
|
||||
- [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
|
||||
- [Distribution](docs/distribution.md) covers package manager setup (WinGet, apt, AUR, Homebrew)
|
||||
- [Auto-Update](docs/auto-update.md) explains the built-in `barn update` command
|
||||
- [Distribution](docs/distribution.md) covers installation methods (Windows setup, Linux binary, Homebrew)
|
||||
- [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
|
||||
- [Manual Testing](docs/testing-manual.md) provides step-by-step manual test procedures
|
||||
@@ -179,4 +179,16 @@
|
||||
<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>
|
||||
+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
|
||||
|
||||
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
|
||||
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
|
||||
barn update
|
||||
```
|
||||
1. Download the latest binary from [GitHub Releases](https://github.com/samson-media/barn/releases/latest)
|
||||
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:
|
||||
---
|
||||
|
||||
```
|
||||
Current version: 1.2.3
|
||||
Latest version: 1.3.0
|
||||
## Windows
|
||||
|
||||
Downloading barn-macos-arm64...
|
||||
Verifying checksum...
|
||||
Installing...
|
||||
Restarting service...
|
||||
To update Barn on Windows:
|
||||
|
||||
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
|
||||
barn update --version=1.2.0
|
||||
```
|
||||
```powershell
|
||||
# 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)
|
||||
|
||||
```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"
|
||||
}
|
||||
# Run silent installation
|
||||
.\setup-barn.exe /S
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 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:
|
||||
- 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:
|
||||
## Checking Your Current Version
|
||||
|
||||
```bash
|
||||
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. 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)
|
||||
```
|
||||
1. Go to https://github.com/samson-media/barn
|
||||
2. Click "Watch" → "Custom" → Select "Releases"
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
- [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 |
|
||||
|----------|---------------|---------------------|
|
||||
| Windows | MSI installer | WinGet |
|
||||
| Linux (Debian/Ubuntu) | .deb | GitHub Releases, optional PPA |
|
||||
| Linux (Arch) | PKGBUILD | AUR |
|
||||
| Windows | Setup installer (.exe) | GitHub Releases |
|
||||
| Linux | Native binary | GitHub Releases |
|
||||
| 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.
|
||||
|
||||
Install WiX:
|
||||
|
||||
```powershell
|
||||
dotnet tool install --global wix
|
||||
```
|
||||
|
||||
### Package Structure
|
||||
Download the latest setup installer from GitHub Releases:
|
||||
|
||||
```
|
||||
packaging/wix/
|
||||
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
|
||||
https://github.com/samson-media/barn/releases/download/v1.2.3/setup-barn-v1.2.3-windows-x64.exe
|
||||
```
|
||||
|
||||
### 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
|
||||
# Download
|
||||
wget https://github.com/samson-media/barn/releases/download/v1.2.3/barn-linux-x64.deb
|
||||
### Silent Installation
|
||||
|
||||
# Install
|
||||
sudo dpkg -i barn-linux-x64.deb
|
||||
For automated deployments:
|
||||
|
||||
# Or with apt (handles dependencies)
|
||||
sudo apt install ./barn-linux-x64.deb
|
||||
```powershell
|
||||
.\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/)
|
||||
2. Create PPA: `ppa:samson-media/barn`
|
||||
3. Upload source package with `dput`
|
||||
4. Users add: `sudo add-apt-repository ppa:samson-media/barn`
|
||||
```powershell
|
||||
"C:\Program Files\Barn\uninstall.exe" /S
|
||||
```
|
||||
|
||||
### 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
|
||||
# Maintainer: Samson Media <support@samson-media.com>
|
||||
pkgname=barn
|
||||
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
|
||||
# Download (x86_64 example)
|
||||
curl -LO https://github.com/samson-media/barn/releases/download/v1.2.3/barn-linux-x64
|
||||
|
||||
package() {
|
||||
install -Dm755 "${srcdir}/${pkgname}-${pkgver}-${CARCH}" "${pkgdir}/usr/bin/barn"
|
||||
install -Dm644 "${srcdir}/barn.service" "${pkgdir}/usr/lib/systemd/system/barn.service"
|
||||
}
|
||||
# Verify checksum
|
||||
curl -LO https://github.com/samson-media/barn/releases/download/v1.2.3/SHA256SUMS
|
||||
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
|
||||
post_install() {
|
||||
systemctl daemon-reload
|
||||
echo ":: Run 'systemctl enable --now barn.service' to start Barn"
|
||||
}
|
||||
# Install the service
|
||||
barn service install
|
||||
|
||||
post_upgrade() {
|
||||
systemctl daemon-reload
|
||||
systemctl try-restart barn.service
|
||||
}
|
||||
# Enable and start the service
|
||||
sudo systemctl enable barn
|
||||
sudo systemctl start barn
|
||||
|
||||
pre_remove() {
|
||||
systemctl stop barn.service || true
|
||||
systemctl disable barn.service || true
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
systemctl daemon-reload
|
||||
}
|
||||
# Verify
|
||||
barn service status
|
||||
```
|
||||
|
||||
### AUR Submission
|
||||
### Updating
|
||||
|
||||
1. Create account at [AUR](https://aur.archlinux.org/)
|
||||
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
|
||||
```
|
||||
To update Barn on Linux:
|
||||
|
||||
### Updating AUR Package
|
||||
|
||||
AUR updates are **automated** via GitHub Actions. See [CI/CD](ci-cd.md#aur-update-workflow) for the workflow details.
|
||||
|
||||
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"
|
||||
}
|
||||
```
|
||||
1. Download the new binary from GitHub Releases
|
||||
2. Stop the service: `sudo systemctl stop barn`
|
||||
3. Replace the binary: `sudo mv barn-linux-x64 /usr/local/bin/barn`
|
||||
4. Start the service: `sudo systemctl start barn`
|
||||
|
||||
---
|
||||
|
||||
@@ -676,10 +261,8 @@ barn --version
|
||||
|
||||
After publishing a GitHub Release:
|
||||
|
||||
1. **Windows**: Submit WinGet manifest PR
|
||||
2. **Arch Linux**: Update AUR PKGBUILD
|
||||
3. **Homebrew**: Formula auto-updates via workflow
|
||||
4. **Debian**: .deb available on GitHub Releases
|
||||
1. **Homebrew**: Formula auto-updates via GitHub Actions workflow
|
||||
2. **Windows/Linux**: Binaries and setup installer available on GitHub Releases (manual download)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -12,9 +12,6 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
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.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
import com.samsonmedia.barn.util.DurationParser;
|
||||
@@ -41,7 +39,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
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")
|
||||
private boolean all;
|
||||
|
||||
@@ -15,9 +15,6 @@ import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
@@ -27,6 +24,7 @@ import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobManifest;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
@@ -43,7 +41,7 @@ import picocli.CommandLine.Parameters;
|
||||
)
|
||||
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
|
||||
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
@@ -6,9 +6,6 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
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.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
|
||||
@@ -35,7 +33,7 @@ import picocli.CommandLine.Parameters;
|
||||
)
|
||||
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")
|
||||
private String jobId;
|
||||
|
||||
@@ -7,9 +7,6 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
@@ -19,6 +16,7 @@ import com.samsonmedia.barn.ipc.IpcClient;
|
||||
import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
@@ -38,7 +36,7 @@ import picocli.CommandLine.Parameters;
|
||||
)
|
||||
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")
|
||||
private String tag;
|
||||
|
||||
@@ -4,11 +4,9 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.config.OperatingSystem;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.platform.linux.SystemdManager;
|
||||
import com.samsonmedia.barn.platform.macos.LaunchdManager;
|
||||
import com.samsonmedia.barn.platform.windows.WindowsServiceManager;
|
||||
@@ -33,7 +31,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
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")
|
||||
private boolean userService;
|
||||
|
||||
@@ -8,10 +8,8 @@ import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.Option;
|
||||
@@ -26,7 +24,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
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";
|
||||
|
||||
@Option(names = {"--follow", "-f"}, description = "Follow log output")
|
||||
|
||||
@@ -6,12 +6,10 @@ import java.nio.file.Path;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.ipc.IpcClient;
|
||||
import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.Option;
|
||||
@@ -26,7 +24,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
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)
|
||||
private Path barnDir;
|
||||
|
||||
@@ -5,11 +5,9 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.execution.ProcessUtils;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.Option;
|
||||
@@ -24,7 +22,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
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;
|
||||
|
||||
@Option(names = {"--force", "-f"}, description = "Force immediate restart")
|
||||
|
||||
@@ -5,12 +5,10 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.Config;
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.config.ConfigLoader;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.service.BarnService;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
@@ -26,7 +24,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
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)")
|
||||
private boolean foreground;
|
||||
|
||||
@@ -11,14 +11,12 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.config.OperatingSystem;
|
||||
import com.samsonmedia.barn.ipc.IpcClient;
|
||||
import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.platform.linux.SystemdManager;
|
||||
import com.samsonmedia.barn.platform.macos.LaunchdManager;
|
||||
import com.samsonmedia.barn.platform.windows.WindowsServiceManager;
|
||||
@@ -38,7 +36,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
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
|
||||
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
@@ -5,11 +5,9 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.execution.ProcessUtils;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.Option;
|
||||
@@ -24,7 +22,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
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;
|
||||
|
||||
@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.Path;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.OperatingSystem;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.platform.linux.SystemdManager;
|
||||
import com.samsonmedia.barn.platform.macos.LaunchdManager;
|
||||
import com.samsonmedia.barn.platform.windows.WindowsServiceManager;
|
||||
@@ -31,7 +29,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
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")
|
||||
private boolean userService;
|
||||
|
||||
@@ -12,9 +12,6 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
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.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
|
||||
@@ -42,7 +40,7 @@ import picocli.CommandLine.Option;
|
||||
)
|
||||
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
|
||||
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
@@ -13,14 +13,12 @@ import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.ConfigDefaults;
|
||||
import com.samsonmedia.barn.ipc.IpcClient;
|
||||
import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.monitoring.UsageLogger;
|
||||
import com.samsonmedia.barn.monitoring.UsageRecord;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
@@ -39,7 +37,7 @@ import picocli.CommandLine.Parameters;
|
||||
)
|
||||
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
|
||||
.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
@@ -12,8 +12,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Loads and validates Barn configuration from files and environment variables.
|
||||
@@ -29,7 +28,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
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 final Map<String, String> environment;
|
||||
|
||||
@@ -6,13 +6,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.Config;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.jobs.RetryCalculator;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
|
||||
@@ -31,7 +29,7 @@ import com.samsonmedia.barn.state.JobState;
|
||||
*/
|
||||
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 final JobRepository repository;
|
||||
|
||||
@@ -7,13 +7,11 @@ import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.JobsConfig;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.jobs.RetryCalculator;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.monitoring.UsageMonitor;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
|
||||
@@ -32,7 +30,7 @@ import com.samsonmedia.barn.state.BarnDirectories;
|
||||
*/
|
||||
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 STDERR_LOG = "stderr.log";
|
||||
|
||||
|
||||
@@ -14,12 +14,10 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.Config;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
|
||||
@@ -31,7 +29,7 @@ import com.samsonmedia.barn.state.JobState;
|
||||
*/
|
||||
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_SHUTDOWN_TIMEOUT = Duration.ofMinutes(5);
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Executes processes and captures their output.
|
||||
@@ -21,7 +20,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
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.
|
||||
|
||||
@@ -9,8 +9,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Monitors a running process and emits events.
|
||||
@@ -20,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
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 final Duration heartbeatInterval;
|
||||
|
||||
@@ -2,8 +2,7 @@ package com.samsonmedia.barn.execution;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Cross-platform process utilities.
|
||||
@@ -13,7 +12,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public final class ProcessUtils {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ProcessUtils.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(ProcessUtils.class);
|
||||
|
||||
private ProcessUtils() {
|
||||
// Utility class - prevent instantiation
|
||||
|
||||
@@ -10,8 +10,7 @@ import java.nio.file.StandardOpenOption;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Lock to ensure only one scheduler runs at a time.
|
||||
@@ -21,7 +20,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
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 FileChannel channel;
|
||||
|
||||
@@ -15,12 +15,10 @@ import java.nio.file.Path;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* IPC client for communicating with the barn service.
|
||||
@@ -30,7 +28,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
*/
|
||||
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 final Path socketPath;
|
||||
|
||||
@@ -18,12 +18,10 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
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.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* IPC server for receiving requests from CLI clients.
|
||||
@@ -32,7 +30,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
*/
|
||||
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 RequestHandler handler;
|
||||
|
||||
@@ -10,13 +10,11 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.samsonmedia.barn.config.JobsConfig;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.AtomicFiles;
|
||||
import com.samsonmedia.barn.state.BarnDirectories;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
@@ -30,7 +28,7 @@ import com.samsonmedia.barn.state.StateFiles;
|
||||
*/
|
||||
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 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.util.Objects;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
|
||||
/**
|
||||
@@ -16,7 +13,7 @@ import com.samsonmedia.barn.jobs.Job;
|
||||
*/
|
||||
public final class JobLogEvents {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JobLogEvents.class);
|
||||
private static final BarnLogger LOG = BarnLogger.getLogger(JobLogEvents.class);
|
||||
|
||||
private JobLogEvents() {
|
||||
// Utility class
|
||||
|
||||
@@ -5,14 +5,8 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
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.
|
||||
*
|
||||
@@ -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
|
||||
* @throws NullPointerException if level is null
|
||||
*/
|
||||
public static void setLogLevel(LogLevel level) {
|
||||
Objects.requireNonNull(level, "level must not be null");
|
||||
|
||||
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);
|
||||
rootLogger.setLevel(toLogbackLevel(level));
|
||||
BarnLogger.enable();
|
||||
BarnLogger.setLevel(toBarnLoggerLevel(level));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,9 +36,7 @@ public final class LoggingConfig {
|
||||
* @return the current log level
|
||||
*/
|
||||
public static LogLevel getLogLevel() {
|
||||
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);
|
||||
return fromLogbackLevel(rootLogger.getLevel());
|
||||
return fromBarnLoggerLevel(BarnLogger.getLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,28 +69,21 @@ public final class LoggingConfig {
|
||||
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) {
|
||||
case DEBUG -> Level.DEBUG;
|
||||
case INFO -> Level.INFO;
|
||||
case WARN -> Level.WARN;
|
||||
case ERROR -> Level.ERROR;
|
||||
case DEBUG -> BarnLogger.Level.DEBUG;
|
||||
case INFO -> BarnLogger.Level.INFO;
|
||||
case WARN -> BarnLogger.Level.WARN;
|
||||
case ERROR -> BarnLogger.Level.ERROR;
|
||||
};
|
||||
}
|
||||
|
||||
private static LogLevel fromLogbackLevel(Level level) {
|
||||
if (level == null || level.equals(Level.INFO)) {
|
||||
return LogLevel.INFO;
|
||||
}
|
||||
if (level.equals(Level.DEBUG) || level.equals(Level.TRACE)) {
|
||||
return LogLevel.DEBUG;
|
||||
}
|
||||
if (level.equals(Level.WARN)) {
|
||||
return LogLevel.WARN;
|
||||
}
|
||||
if (level.equals(Level.ERROR) || level.equals(Level.OFF)) {
|
||||
return LogLevel.ERROR;
|
||||
}
|
||||
return LogLevel.INFO;
|
||||
private static LogLevel fromBarnLoggerLevel(BarnLogger.Level level) {
|
||||
return switch (level) {
|
||||
case DEBUG -> LogLevel.DEBUG;
|
||||
case INFO -> LogLevel.INFO;
|
||||
case WARN -> LogLevel.WARN;
|
||||
case ERROR, OFF -> LogLevel.ERROR;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,7 @@ import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Collects resource usage metrics for a process.
|
||||
@@ -22,7 +21,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
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 final boolean isWindows;
|
||||
|
||||
@@ -8,8 +8,7 @@ import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Writes usage records to a CSV file.
|
||||
@@ -18,7 +17,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
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. */
|
||||
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.atomic.AtomicBoolean;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Monitors resource usage for a process over time.
|
||||
@@ -20,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
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. */
|
||||
public static final int DEFAULT_INTERVAL_SECONDS = 5;
|
||||
|
||||
@@ -11,8 +11,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Manages Linux systemd service operations.
|
||||
@@ -22,7 +21,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
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 long COMMAND_TIMEOUT_SECONDS = 30;
|
||||
|
||||
|
||||
@@ -9,8 +9,7 @@ import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Manages macOS launchd service operations.
|
||||
@@ -20,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
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 long COMMAND_TIMEOUT_SECONDS = 30;
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@ import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* Manages Windows service operations using sc.exe.
|
||||
@@ -21,7 +20,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
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 DISPLAY_NAME = "Barn Job Daemon";
|
||||
private static final long COMMAND_TIMEOUT_SECONDS = 30;
|
||||
|
||||
@@ -9,9 +9,6 @@ import java.util.Objects;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.samsonmedia.barn.config.Config;
|
||||
@@ -24,6 +21,7 @@ import com.samsonmedia.barn.ipc.IpcException;
|
||||
import com.samsonmedia.barn.ipc.IpcServer;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
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.JobState;
|
||||
@@ -41,7 +39,7 @@ import com.samsonmedia.barn.state.JobState;
|
||||
*/
|
||||
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 BarnDirectories dirs;
|
||||
|
||||
@@ -10,12 +10,10 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.samsonmedia.barn.config.CleanupConfig;
|
||||
import com.samsonmedia.barn.jobs.Job;
|
||||
import com.samsonmedia.barn.jobs.JobRepository;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
import com.samsonmedia.barn.state.JobState;
|
||||
|
||||
/**
|
||||
@@ -23,7 +21,7 @@ import com.samsonmedia.barn.state.JobState;
|
||||
*/
|
||||
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 CleanupConfig config;
|
||||
|
||||
@@ -9,8 +9,7 @@ import java.nio.file.StandardOpenOption;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.samsonmedia.barn.logging.BarnLogger;
|
||||
|
||||
/**
|
||||
* A file-based lock for coordinating access to resources.
|
||||
@@ -20,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
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 FileChannel channel;
|
||||
|
||||
+42
-168
@@ -1,187 +1,61 @@
|
||||
[
|
||||
{
|
||||
"name": "com.samsonmedia.barn.ipc.IpcMessage",
|
||||
"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",
|
||||
"name": "ch.qos.logback.core.status.NopStatusListener",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true
|
||||
},
|
||||
{
|
||||
"name": "java.util.HashMap",
|
||||
"name": "ch.qos.logback.core.helpers.NOPAppender",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true
|
||||
},
|
||||
{
|
||||
"name": "java.util.ArrayList",
|
||||
"name": "ch.qos.logback.core.FileAppender",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true
|
||||
},
|
||||
{
|
||||
"name": "java.util.ImmutableCollections$ListN",
|
||||
"name": "ch.qos.logback.core.rolling.RollingFileAppender",
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicConstructors": true
|
||||
"allPublicConstructors": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allPublicMethods": true
|
||||
},
|
||||
{
|
||||
"name": "java.util.ImmutableCollections$List12",
|
||||
"name": "ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy",
|
||||
"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,40 +1,24 @@
|
||||
<configuration>
|
||||
<!-- Suppress logback's internal status messages -->
|
||||
<configuration debug="false">
|
||||
<!-- Suppress ALL logback output including internal status -->
|
||||
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
|
||||
|
||||
<!-- File appender for service logging -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${BARN_LOG_DIR:-${java.io.tmpdir}/barn/logs}/barn.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${BARN_LOG_DIR:-${java.io.tmpdir}/barn/logs}/barn.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
<maxHistory>7</maxHistory>
|
||||
<totalSizeCap>100MB</totalSizeCap>
|
||||
</rollingPolicy>
|
||||
<!-- NOP appender - discards all logs -->
|
||||
<appender name="NOP" class="ch.qos.logback.core.helpers.NOPAppender"/>
|
||||
|
||||
<!-- File appender for service logging (only used when service enables it) -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||
<file>/tmp/barn/logs/barn.log</file>
|
||||
<append>true</append>
|
||||
<encoder>
|
||||
<pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- JSON appender for structured logging -->
|
||||
<appender name="JSON" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${BARN_LOG_DIR:-${java.io.tmpdir}/barn/logs}/barn.json.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${BARN_LOG_DIR:-${java.io.tmpdir}/barn/logs}/barn.json.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
<maxHistory>7</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
|
||||
<includeMdcKeyName>jobId</includeMdcKeyName>
|
||||
<includeMdcKeyName>jobTag</includeMdcKeyName>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!--
|
||||
Root logger OFF by default - CLI commands produce no log output.
|
||||
Service startup explicitly enables logging via LoggingConfig.
|
||||
-->
|
||||
<root level="OFF">
|
||||
<appender-ref ref="FILE"/>
|
||||
<appender-ref ref="NOP"/>
|
||||
</root>
|
||||
</configuration>
|
||||
Reference in new issue
Block a user