Mining

GoLang Miner management with embedable RESTful control - A modern, modular package for managing cryptocurrency miners.
miner-cli serve --host localhost --port 9090 --namespace /api/v1/mining
<script type="module" src="./mbe-mining-dashboard.js"></script>
<mde-mining-dashboard miner-name="xmrig" wallet="..." pool="..." api-base-url="http://localhost:9090/api/v1/mining"></mde-mining-dashboard>
Overview
Mining is a Go package designed to provide comprehensive miner management capabilities. It can be used both as a standalone CLI tool and as a module/plugin in other Go projects. The package offers:
- Miner Lifecycle Management: Start, stop, and monitor miners
- Status Tracking: Real-time status and hash rate monitoring
- CLI Interface: Easy-to-use command-line interface built with Cobra
- Modular Design: Import as a package in your own projects
- RESTful Ready: Designed for integration with RESTful control systems
Features
- ✅ Start and stop miners programmatically
- ✅ Monitor miner status and performance
- ✅ Track hash rates
- ✅ List all active miners
- ✅ CLI for easy management
- ✅ Designed as a reusable Go module
- ✅ Comprehensive test coverage
- ✅ Standards-compliant configuration (CodeRabbit, GoReleaser)
Installation
go install github.com/Snider/Mining/cmd/mining@latest
As a Go Module
go get github.com/Snider/Mining
Usage
CLI Commands
The miner-cli provides the following commands:
miner-cli completion Generate the autocompletion script for the specified shell
miner-cli doctor Check and refresh the status of installed miners
miner-cli help Help about any command
miner-cli install Install or update a miner
miner-cli list List running and available miners
miner-cli serve Start the mining service and interactive shell
miner-cli start Start a new miner
miner-cli status Get status of a running miner
miner-cli stop Stop a running miner
miner-cli uninstall Uninstall a miner
miner-cli update Check for updates to installed miners
For more details on any command, use miner-cli [command] --help.
RESTful API Endpoints
When running the miner-cli serve command, the following RESTful API endpoints are exposed (default base path /api/v1/mining):
GET /api/v1/mining/info - Get cached miner installation information and system details.
POST /api/v1/mining/doctor - Perform a live check on all available miners to verify their installation status, version, and path.
POST /api/v1/mining/update - Check if any installed miners have a new version available for download.
GET /api/v1/mining/miners - Get a list of all running miners.
GET /api/v1/mining/miners/available - Get a list of all available miners.
POST /api/v1/mining/miners/:miner_name - Start a new miner with the given configuration.
POST /api/v1/mining/miners/:miner_name/install - Install a new miner or update an existing one.
DELETE /api/v1/mining/miners/:miner_name/uninstall - Remove all files for a specific miner.
DELETE /api/v1/mining/miners/:miner_name - Stop a running miner by its name.
GET /api/v1/mining/miners/:miner_name/stats - Get statistics for a running miner.
GET /api/v1/mining/swagger/*any - Serve Swagger UI for API documentation.
Swagger documentation is typically available at http://<host>:<port>/api/v1/mining/swagger/index.html.
Development
Prerequisites
- Go 1.24 or higher
- Make (optional, for using Makefile targets)
Build
# Build the CLI
go build -o miner-cli ./cmd/mining
# Run tests
go test ./...
# Run tests with coverage
go test -cover ./...
Project Structure
.
├── cmd/
│ └── mining/ # CLI application
│ ├── main.go # CLI entry point
│ └── cmd/ # Cobra commands
├── pkg/
│ └── mining/ # Core mining package
│ ├── mining.go # Main package code
│ └── mining_test.go
├── main.go # Demo/development main
├── .coderabbit.yaml # CodeRabbit configuration
├── .goreleaser.yaml # GoReleaser configuration
├── .gitignore
├── go.mod
├── LICENSE
└── README.md
Configuration
CodeRabbit
The project uses CodeRabbit for automated code reviews. Configuration is in .coderabbit.yaml.
GoReleaser
Releases are managed with GoReleaser. Configuration is in .goreleaser.yaml. To create a release:
# Tag a version
git tag -a v0.1.0 -m "Release v0.1.0"
git push origin v0.1.0
# GoReleaser will automatically build and publish
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add some amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
License
This project is licensed under the EUPL-1.2 License - see the LICENSE file for details.
Acknowledgments
Support
For issues, questions, or contributions, please open an issue on GitHub.