Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create scheduler (resolves #646) #687

Merged
merged 18 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions .deploy/accessibility-app/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,7 @@ then

touch $FILES_PATH/../deploy.lock

if [ "$APP_ENV" == "production" ]
then
php artisan migrate --step --force
else
php artisan migrate:fresh --step
php artisan db:seed DevSeeder
fi

php artisan google-fonts:fetch
php artisan storage:link
php artisan cache:clear
php artisan view:clear
php artisan optimize
php artisan event:cache
php artisan deploy:initial

fi

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
git checkout dev && \
git pull && \
/usr/local/bin/docker-compose -f docker-compose.cloud.yml up -d --force-recreate && \
/usr/local/bin/docker-compose -f docker-compose.cloud.yml exec -T app composer install --optimize-autoloader && \
/usr/local/bin/docker-compose -f docker-compose.cloud.yml exec -T app ./artisan migrate:fresh --force && \
/usr/local/bin/docker-compose -f docker-compose.cloud.yml exec -T app composer install --optimize-autoloader && \
/usr/local/bin/docker-compose -f docker-compose.cloud.yml exec -T app ./artisan migrate:fresh --force && \
/usr/local/bin/docker-compose -f docker-compose.cloud.yml exec -T app ./artisan db:seed DevSeeder --force && \
/usr/local/bin/docker-compose -f docker-compose.cloud.yml exec -T app ./artisan view:clear && \
/usr/local/bin/docker-compose -f docker-compose.cloud.yml exec -T app ./artisan storage:link && \
Expand Down
38 changes: 38 additions & 0 deletions app/Console/Commands/DatabaseRefresh.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class DatabaseRefresh extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'db:refresh';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Refreshes and seeds the database for development work.';

/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
// don't run command in production or testing environment
if (in_array(config('app.env'), ['testing', 'production']) !== true) {
$this->call('migrate:fresh', ['--force' => true]);
$this->call('db:seed', ['DevSeeder', '--force' => true]);
}

return 0;
}
}
46 changes: 46 additions & 0 deletions app/Console/Commands/DeployInitial.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class DeployInitial extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'deploy:initial';

/**
* The console command description.
*
* @var string
*/
protected $description = 'All commands that should be run when a container boots.';

/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
// split migrate commands between production and development versions
if (config('app.env') === 'production') {
$this->call('migrate', ['--step' => true, '--force' => true]);
} else {
$this->call('db:refresh');
}

$this->call('google-fonts:fetch');
$this->call('storage:link');
$this->call('cache:clear');
$this->call('view:clear');
$this->call('optimize');
$this->call('event:cache');

return 0;
}
}
5 changes: 4 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$schedule->command('db:refresh') // use custom command to make sure that the commands are chained
->daily() // Run daily at midnight
->environments(['staging', 'dev', 'local']) // only run for APP_ENV tagged staging, dev, or local
->onOneServer(); // run only on a single server at once
}

/**
Expand Down