Commit 82dcab0a by Phạm Văn Đoan

tạo Crontjob.php test

parent 306fdb5b
...@@ -6,11 +6,18 @@ APP_LOG_LEVEL=debug ...@@ -6,11 +6,18 @@ APP_LOG_LEVEL=debug
APP_URL=http://localhost APP_URL=http://localhost
DB_CONNECTION=mysql DB_CONNECTION=mysql
DB_HOST=127.0.0.1 DB_HOST=127.0.0.1
DB_PORT=3306 DB_PORT=3306
DB_DATABASE=homestead DB_DATABASE=vmusicchart
DB_USERNAME=homestead DB_USERNAME=vmusic
DB_PASSWORD=secret DB_PASSWORD=Vmusic@2019###
DB_LOCAL_HOST=127.0.0.1
DB_LOCAL_PORT=3306
DB_LOCAL_DATABASE=vmusicchart
DB_LOCAL_USERNAME=root
DB_LOCAL_PASSWORD=
BROADCAST_DRIVER=log BROADCAST_DRIVER=log
CACHE_DRIVER=file CACHE_DRIVER=file
......
...@@ -8,3 +8,4 @@ ...@@ -8,3 +8,4 @@
Homestead.json Homestead.json
Homestead.yaml Homestead.yaml
.env .env
/composer.lock
<?php
namespace App\Console\Commands;
use App\Models\Crontjob;
use Carbon\Carbon;
use Illuminate\Console\Command;
class CrontjobCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'crontjob:test';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
Crontjob::create(['message' => 'Crontjob is called at ' . Carbon::now()]);
}
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Console; namespace App\Console;
use App\Console\Commands\CrontjobCommand;
use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
...@@ -13,7 +14,7 @@ class Kernel extends ConsoleKernel ...@@ -13,7 +14,7 @@ class Kernel extends ConsoleKernel
* @var array * @var array
*/ */
protected $commands = [ protected $commands = [
// CrontjobCommand::class,
]; ];
/** /**
...@@ -26,6 +27,10 @@ class Kernel extends ConsoleKernel ...@@ -26,6 +27,10 @@ class Kernel extends ConsoleKernel
{ {
// $schedule->command('inspire') // $schedule->command('inspire')
// ->hourly(); // ->hourly();
$schedule->command('crontjob:test')->everyMinute();
$schedule->command('queue:work --once --timeout=120')->everyMinute()->withoutOverlapping();
} }
/** /**
......
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Crontjob extends Model
{
protected $table = 'crontjobs';
public $timestamps = true;
protected $fillable = ['message'];
}
...@@ -41,16 +41,16 @@ return [ ...@@ -41,16 +41,16 @@ return [
'mysql' => [ 'mysql' => [
'driver' => 'mysql', 'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'), 'host' => (env('APP_ENV') == 'production') ? env('DB_HOST') : env('DB_LOCAL_HOST'),
'port' => env('DB_PORT', '3306'), 'port' => (env('APP_ENV') == 'production') ? env('DB_PORT') : env('DB_LOCAL_PORT'),
'database' => env('DB_DATABASE', 'forge'), 'database' => (env('APP_ENV') == 'production') ? env('DB_DATABASE') : env('DB_LOCAL_DATABASE'),
'username' => env('DB_USERNAME', 'forge'), 'username' => (env('APP_ENV') == 'production') ? env('DB_USERNAME') : env('DB_LOCAL_USERNAME'),
'password' => env('DB_PASSWORD', ''), 'password' => (env('APP_ENV') == 'production') ? env('DB_PASSWORD') : env('DB_LOCAL_PASSWORD'),
'unix_socket' => env('DB_SOCKET', ''), 'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4', 'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci', 'collation' => 'utf8mb4_unicode_ci',
'prefix' => '', 'prefix' => '',
'strict' => true, 'strict' => false,
'engine' => null, 'engine' => null,
], ],
......
Markdown is supported
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