Commit 5bb8fd6b authored by Dillenn Terumalai's avatar Dillenn Terumalai
Browse files

// WIP

parent c24595e9
......@@ -2,6 +2,6 @@
All notable changes to `laravel-cluster` will be documented in this file.
## 1.0.0 - 202X-XX-XX
## 1.0.0 - 2021-06-30
- initial release
- Initial release
# Laravel Cluster provides a unified queueing API and dashboard for cluster systems
<p align="center"><img src="https://banners.beyondco.de/Laravel%20Cluster.png?theme=light&packageManager=composer+require&packageName=dterumal%2Flaravel-cluster&pattern=architect&style=style_1&description=Unified+queueing+API+and+dashboard+for+cluster+systems&md=1&showWatermark=1&fontSize=100px&images=chip"></p>
[![Latest Version on Packagist](https://img.shields.io/packagist/v/dterumal/laravel-cluster.svg?style=flat-square)](https://packagist.org/packages/dterumal/laravel-cluster)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/dterumal/laravel-cluster/run-tests?label=tests)](https://github.com/dterumal/laravel-cluster/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/dterumal/laravel-cluster/Check%20&%20fix%20styling?label=code%20style)](https://github.com/dterumal/laravel-cluster/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/dterumal/laravel-cluster.svg?style=flat-square)](https://packagist.org/packages/dterumal/laravel-cluster)
## Introduction
---
This repo can be used as to scaffold a Laravel package. Follow these steps to get started:
Laravel cluster provides a beautiful dashboard and code-driven configuration for your Laravel powered cluster. Larvel cluster allows you to easily monitor key metrics of your cluster system such as job throughput, runtime, and job failures.
1. Press the "Use template" button at the top of this repo to create a new repo with the contents of this laravel-cluster
2. Run "./configure-laravel-cluster.sh" to run a script that will replace all placeholders throughout all the files
3. Remove this block of text.
4. Have fun creating your package.
5. If you need help creating a package, consider picking up our <a href="https://laravelpackage.training">Laravel Package Training</a> video course.
---
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
## Support us
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/laravel-cluster.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/laravel-cluster)
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
All of your cluster configuration is stored in a single, simple configuration file, allowing your configuration to stay in source control where your entire team can collaborate.
## Installation
You can install the package via composer:
```bash
composer config repositories.gitlab.sib.swiss/519 '{"type": "composer", "url": "https://gitlab.sib.swiss/api/v4/group/519/-/packages/composer/packages.json"}'
composer require dterumal/laravel-cluster
```
You can publish and run the migrations with:
After installing Horizon, publish its assets using the `laravel-cluster:install` Artisan command:
```bash
php artisan vendor:publish --provider="Dterumal\LaravelCluster\LaravelClusterServiceProvider" --tag="laravel-cluster-migrations"
php artisan migrate
php artisan laravel-cluster:install
```
You can publish the config file with:
```bash
php artisan vendor:publish --provider="Dterumal\LaravelCluster\LaravelClusterServiceProvider" --tag="laravel-cluster-config"
### Configuration
After publishing Laravel cluster's assets, its primary configuration file will be located at `config/laravel-cluster.php`. This configuration file allows you to configure the queue worker options for your application. Each configuration option includes a description of its purpose, so be sure to thoroughly explore this file.
### Migrations
You should also find a migration file `database/migrations/xxxx_xx_xx_xxxxxx_create_cluster_jobs_table` which will create a table to store your jobs information. Make sure that your application is using a database.
### Dashboard Authorization
Laravel cluster exposes a dashboard at the `/laravel-cluster` URI. By default, you will only be able to access this dashboard in the local environment. However, within your app/Providers/LaravelClusterServiceProvider.php file, there is an authorization gate definition. This authorization gate controls access to Laravel cluster in non-local environments. You are free to modify this gate as needed to restrict access to your Laravel cluster installation:
```php
/**
* Register the LaravelCluster gate.
*
* This gate determines who can access LaravelCluster in non-local environments.
*
* @return void
*/
protected function gate()
{
Gate::define('viewLaravelCluster', function ($user) {
return in_array($user->email, [
'dillenn.terumalai@sib.swiss',
], true);
});
}
```
This is the contents of the published config file:
### Cluster live information
Laravel cluster includes a metrics dashboard which provides information regarding your jobs. In order to keep this dashboard up to date, you should configure Laravel cluster's `refresh` Artisan command to run every minute via your application's scheduler:
```php
return [
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('laravel-cluster:refresh')->everyFiveMinutes();
}
```
## Usage
### Notifications
If you would like to be notified when the cluster is unreachable, you may use the LaravelCluster::routeMailNotificationsTo method. You may call this method from the boot method of your application's App\Providers\LaravelClusterServiceProvider:
```php
$laravel-cluster = new Dterumal\LaravelCluster();
echo $laravel-cluster->echoPhrase('Hello, Spatie!');
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
parent::boot();
LaravelCluster::routeMailNotificationsTo('example@example.com');
}
```
### Clearing jobs from queue
If you would like to delete all pending jobs from the cluster's queue, you may do so using the `laravel-cluster:clear` Artisan command:
```bash
php artisan horizon:clear
```
## Testing
......@@ -71,16 +106,18 @@ Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed re
## Contributing
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
Please see [CONTRIBUTING](.gitlab/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
Please review [our security policy](.gitlab/SECURITY.md) on how to report security vulnerabilities.
## Credits
- [Dillenn Terumalai](https://github.com/dterumal)
- [All Contributors](../../contributors)
This package is highly inspired from [Laravel Horizon](https://github.com/laravel/horizon).
- [Dillenn Terumalai](https://gitlab.sib.swiss/dterumal)
- [Spatie/Package-Skeleton-Laravel](https://github.com/spatie/package-skeleton-laravel)
## License
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment