mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Laravel Horizon. (#3517)
* Fixes for white label * Include Laravel Horizon
This commit is contained in:
parent
ac5525c9ac
commit
374a44aa55
@ -40,6 +40,10 @@ class Kernel extends ConsoleKernel
|
||||
|
||||
//$schedule->job(new RecurringInvoicesCron)->hourly();
|
||||
$schedule->job(new VersionCheck)->daily();
|
||||
|
||||
/* Build queue snapshots */
|
||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,8 +83,8 @@ class LicenseController extends BaseController
|
||||
{
|
||||
|
||||
/* Catch claim license requests */
|
||||
if (config('ninja.environment') == 'selfhost' && $request->has('license_key')) {
|
||||
$license_key = $request->input('license_key');
|
||||
if (config('ninja.environment') == 'selfhost' && request()->has('license_key')) {
|
||||
$license_key = request()->input('license_key');
|
||||
$product_id = 3;
|
||||
|
||||
$url = config('ninja.license_url') . "/claim_license?license_key={$license_key}&product_id={$product_id}&get_date=true";
|
||||
@ -134,7 +134,7 @@ class LicenseController extends BaseController
|
||||
}
|
||||
|
||||
$error = [
|
||||
'message' => trans('texts.invalid_white_label_license'),
|
||||
'message' => "Invalid license, or invalid environment ".config('ninja.environment')s,
|
||||
'errors' => []
|
||||
];
|
||||
|
||||
|
@ -646,15 +646,19 @@ class UserController extends BaseController
|
||||
*/
|
||||
public function detach(DetachCompanyUserRequest $request, User $user)
|
||||
{
|
||||
|
||||
$company_user = CompanyUser::whereUserId($user->id)
|
||||
->whereCompanyId(auth()->user()->companyId())->first();
|
||||
|
||||
$token = $company_user->token->where('company_id', $company_user->company_id)->where('user_id', $company_user->user_id)->first();
|
||||
|
||||
$token->delete();
|
||||
if($token)
|
||||
$token->delete();
|
||||
|
||||
$company_user->delete();
|
||||
if($company_user)
|
||||
$company_user->delete();
|
||||
|
||||
return response()->json(['message' => 'User detached from company'], 200);
|
||||
|
||||
}
|
||||
}
|
||||
|
42
app/Providers/HorizonServiceProvider.php
Normal file
42
app/Providers/HorizonServiceProvider.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Horizon\Horizon;
|
||||
use Laravel\Horizon\HorizonApplicationServiceProvider;
|
||||
|
||||
class HorizonServiceProvider extends HorizonApplicationServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
// Horizon::routeSmsNotificationsTo('15556667777');
|
||||
// Horizon::routeMailNotificationsTo('example@example.com');
|
||||
// Horizon::routeSlackNotificationsTo('slack-webhook-url', '#channel');
|
||||
|
||||
// Horizon::night();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the Horizon gate.
|
||||
*
|
||||
* This gate determines who can access Horizon in non-local environments.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function gate()
|
||||
{
|
||||
Gate::define('viewHorizon', function ($user) {
|
||||
return in_array($user->email, [
|
||||
//
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
@ -26,11 +26,13 @@
|
||||
"dacastro4/laravel-gmail": "^3.2",
|
||||
"davejamesmiller/laravel-breadcrumbs": "5.x",
|
||||
"fideloper/proxy": "^4.0",
|
||||
"fzaninotto/faker": "^1.4",
|
||||
"google/apiclient": "^2.0",
|
||||
"hashids/hashids": "^3.0",
|
||||
"intervention/image": "^2.4",
|
||||
"laracasts/presenter": "^0.2.1",
|
||||
"laravel/framework": "^6",
|
||||
"laravel/horizon": "3.7.2",
|
||||
"laravel/slack-notification-channel": "^2.0",
|
||||
"laravel/socialite": "^4.0",
|
||||
"laravel/tinker": "^1.0",
|
||||
@ -46,8 +48,7 @@
|
||||
"staudenmeir/eloquent-has-many-deep": "^1.11",
|
||||
"stripe/stripe-php": "^7.0",
|
||||
"superbalist/laravel-google-cloud-storage": "^2.2",
|
||||
"webpatser/laravel-countries": "dev-master#75992ad",
|
||||
"fzaninotto/faker": "^1.4"
|
||||
"webpatser/laravel-countries": "dev-master#75992ad"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravelcollective/html": "^6",
|
||||
@ -109,4 +110,4 @@
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
}
|
||||
|
@ -176,6 +176,7 @@ return [
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
// App\Providers\BroadcastServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\HorizonServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
App\Providers\ComposerServiceProvider::class,
|
||||
Codedge\Updater\UpdaterServiceProvider::class,
|
||||
|
164
config/horizon.php
Normal file
164
config/horizon.php
Normal file
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Horizon Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the subdomain where Horizon will be accessible from. If this
|
||||
| setting is null, Horizon will reside under the same domain as the
|
||||
| application. Otherwise, this value will serve as the subdomain.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Horizon Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the URI path where Horizon will be accessible from. Feel free
|
||||
| to change this path to anything you like. Note that the URI will not
|
||||
| affect the paths of its internal API that aren't exposed to users.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => 'horizon',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Horizon Redis Connection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the name of the Redis connection where Horizon will store the
|
||||
| meta information required for it to function. It includes the list
|
||||
| of supervisors, failed jobs, job metrics, and other information.
|
||||
|
|
||||
*/
|
||||
|
||||
'use' => 'default',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Horizon Redis Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This prefix will be used when storing all Horizon data in Redis. You
|
||||
| may modify the prefix when you are running multiple installations
|
||||
| of Horizon on the same server so that they don't have problems.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('HORIZON_PREFIX', 'horizon:'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Horizon Route Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These middleware will get attached onto each Horizon route, giving you
|
||||
| the chance to add your own middleware to this list or change any of
|
||||
| the existing middleware. Or, you can simply stick with this list.
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => ['web'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Wait Time Thresholds
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to configure when the LongWaitDetected event
|
||||
| will be fired. Every connection / queue combination may have its
|
||||
| own, unique threshold (in seconds) before this event is fired.
|
||||
|
|
||||
*/
|
||||
|
||||
'waits' => [
|
||||
'redis:default' => 60,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Job Trimming Times
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you can configure for how long (in minutes) you desire Horizon to
|
||||
| persist the recent and failed jobs. Typically, recent jobs are kept
|
||||
| for one hour while all failed jobs are stored for an entire week.
|
||||
|
|
||||
*/
|
||||
|
||||
'trim' => [
|
||||
'recent' => 60,
|
||||
'completed' => 60,
|
||||
'recent_failed' => 10080,
|
||||
'failed' => 10080,
|
||||
'monitored' => 10080,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fast Termination
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When this option is enabled, Horizon's "terminate" command will not
|
||||
| wait on all of the workers to terminate unless the --wait option
|
||||
| is provided. Fast termination can shorten deployment delay by
|
||||
| allowing a new instance of Horizon to start while the last
|
||||
| instance will continue to terminate each of its workers.
|
||||
|
|
||||
*/
|
||||
|
||||
'fast_termination' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Memory Limit (MB)
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value describes the maximum amount of memory the Horizon worker
|
||||
| may consume before it is terminated and restarted. You should set
|
||||
| this value according to the resources available to your server.
|
||||
|
|
||||
*/
|
||||
|
||||
'memory_limit' => 256,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Worker Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the queue worker settings used by your application
|
||||
| in all environments. These supervisors and settings handle all your
|
||||
| queued jobs and will be provisioned by Horizon during deployment.
|
||||
|
|
||||
*/
|
||||
|
||||
'environments' => [
|
||||
'production' => [
|
||||
'supervisor-1' => [
|
||||
'connection' => 'redis',
|
||||
'queue' => ['default'],
|
||||
'balance' => 'simple',
|
||||
'processes' => 10,
|
||||
'tries' => 1,
|
||||
],
|
||||
],
|
||||
|
||||
'local' => [
|
||||
'supervisor-1' => [
|
||||
'connection' => 'redis',
|
||||
'queue' => ['default'],
|
||||
'balance' => 'simple',
|
||||
'processes' => 3,
|
||||
'tries' => 1,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
@ -118,6 +118,8 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
|
||||
|
||||
Route::post('self-update/check_version', 'SelfUpdateController@checkVersion');
|
||||
|
||||
Route::post('claim_license', 'LicenseController@index')->name('license.index');
|
||||
|
||||
/*
|
||||
Route::resource('tasks', 'TaskController'); // name = (tasks. index / create / show / update / destroy / edit
|
||||
|
||||
@ -136,9 +138,5 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
|
||||
Route::post('support/messages/send', 'Support\Messages\SendingController');
|
||||
});
|
||||
|
||||
Route::group(['middleware' => ['api_db', 'locale'], 'prefix' => 'api/v1', 'as' => 'api.'], function () {
|
||||
Route::post('claim_license', 'LicenseController@index')->name('license.index');
|
||||
//Route::post('register_user', 'LicenseController@registerNinjaUser')->name('license.register_ninja_user');
|
||||
});
|
||||
|
||||
Route::fallback('BaseController@notFound');
|
||||
|
Loading…
x
Reference in New Issue
Block a user