What I want:
For my deployment to take less time to update the newly released folder.
Steps
-
Setup deploy.php and gitlab-ci (works) for Gitlab
-
Using https://github.com/deployphp/deployer/blob/master/recipe/laravel.php with my own tweaks to it
-
Pushing changes to main
-
Job is running
-
Job completed
-
Folder structure on my server's website root now:
/shared
/current -> (latest version_number symlink)
/releases/(latest version_number) -
Website path is: /path/to/website/current/public
What is happening"
After a successfull deployment, the deployer generates a new release and symlinks the current folder to that new release.
For example: /current -> /releases/10
All the other versions, from /releases/1 to /releases/9 are still there. But due to the website calling current, which is always symlinked to the latest release this should awork.
I expect it to take a minute or 2 to update... but how wrong I am. It now takes around a full day.
Before you ask yes I did do:
php artisan optimize:clear (if that's the correct thing to do) and I also tried doing them seperately on the current folder and latest release folder
I also added a command to laravel which is opcache:clear:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class ClearOpcache extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'opcache:clear';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Clear the PHP OPcache';
/**
* Execute the console command.
*/
public function handle()
{
if (function_exists('opcache_reset')) {
opcache_reset();
$this->info('OPcache cleared!');
} else {
$this->error('OPcache is not enabled.');
}
}
}
And added this to my deploy.php, which shows 'OPcache cleared!' in the job that's running.
This doesn't seem to change it....
Does anyone know how to resolve this? And if so, please explain me how to because my caching knowledge is really bad....