new deployer command
This commit is contained in:
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Exceptions\DatabaseStageException;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Process;
|
use Illuminate\Support\Facades\Process;
|
||||||
use RuntimeException;
|
|
||||||
|
|
||||||
class DatabaseStage extends Command
|
class DatabaseStage extends Command
|
||||||
{
|
{
|
||||||
@@ -133,13 +133,13 @@ class DatabaseStage extends Command
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if ($result->failed()) {
|
if ($result->failed()) {
|
||||||
throw new RuntimeException(
|
throw new DatabaseStageException(
|
||||||
"pg_dump failed:\n" . $result->errorOutput(),
|
"pg_dump failed:\n" . $result->errorOutput(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! file_exists($localDump) || filesize($localDump) === 0) {
|
if (! file_exists($localDump) || filesize($localDump) === 0) {
|
||||||
throw new RuntimeException('Database dump was not created or is empty.');
|
throw new DatabaseStageException('Database dump was not created or is empty.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -166,7 +166,7 @@ class DatabaseStage extends Command
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if ($result->failed()) {
|
if ($result->failed()) {
|
||||||
throw new RuntimeException(
|
throw new DatabaseStageException(
|
||||||
"Invalid PostgreSQL archive:\n" . $result->errorOutput(),
|
"Invalid PostgreSQL archive:\n" . $result->errorOutput(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -193,7 +193,7 @@ class DatabaseStage extends Command
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if ($result->failed()) {
|
if ($result->failed()) {
|
||||||
throw new RuntimeException(
|
throw new DatabaseStageException(
|
||||||
"Upload failed:\n" . $result->errorOutput(),
|
"Upload failed:\n" . $result->errorOutput(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -252,7 +252,7 @@ SQL;
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if ($result->failed()) {
|
if ($result->failed()) {
|
||||||
throw new RuntimeException(
|
throw new DatabaseStageException(
|
||||||
"Unable to recreate stage database:\n" .
|
"Unable to recreate stage database:\n" .
|
||||||
$result->errorOutput(),
|
$result->errorOutput(),
|
||||||
);
|
);
|
||||||
@@ -299,7 +299,7 @@ SQL;
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if ($result->failed()) {
|
if ($result->failed()) {
|
||||||
throw new RuntimeException(
|
throw new DatabaseStageException(
|
||||||
"Database restore failed:\n" .
|
"Database restore failed:\n" .
|
||||||
$result->errorOutput(),
|
$result->errorOutput(),
|
||||||
);
|
);
|
||||||
@@ -345,7 +345,7 @@ SQL;
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if ($result->failed()) {
|
if ($result->failed()) {
|
||||||
throw new RuntimeException(
|
throw new DatabaseStageException(
|
||||||
"Database verification failed:\n" .
|
"Database verification failed:\n" .
|
||||||
$result->errorOutput(),
|
$result->errorOutput(),
|
||||||
);
|
);
|
||||||
|
|||||||
+15
-12
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Deployer;
|
namespace Deployer;
|
||||||
|
|
||||||
require_once 'recipe/laravel.php';
|
require 'recipe/laravel.php';
|
||||||
|
|
||||||
set('writable_use_sudo', true);
|
set('writable_use_sudo', true);
|
||||||
set('clear_use_sudo', true);
|
set('clear_use_sudo', true);
|
||||||
@@ -12,6 +12,9 @@ set('repository', 'git@git.absdev.net:mag/WMS.git');
|
|||||||
set('node_version', '22.12.0');
|
set('node_version', '22.12.0');
|
||||||
set('allow_anonymous_stats', false);
|
set('allow_anonymous_stats', false);
|
||||||
|
|
||||||
|
const RELEASE_CD = 'cd {{release_path}} && ';
|
||||||
|
const DEPLOY_SYMLINK = 'deploy:symlink';
|
||||||
|
|
||||||
add('shared_files', ['.env']);
|
add('shared_files', ['.env']);
|
||||||
add('shared_dirs', ['storage']);
|
add('shared_dirs', ['storage']);
|
||||||
add('writable_dirs', ['storage', 'bootstrap/cache']);
|
add('writable_dirs', ['storage', 'bootstrap/cache']);
|
||||||
@@ -70,30 +73,30 @@ task('build', function (): void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
task('queue:restart', function (): void {
|
task('queue:restart', function (): void {
|
||||||
run('cd {{release_path}} && php artisan queue:restart');
|
run(RELEASE_CD . 'php artisan queue:restart');
|
||||||
});
|
});
|
||||||
|
|
||||||
task('deploy:write_revision_file', function (): void {
|
task('deploy:write_revision_file', function (): void {
|
||||||
run('cd {{release_path}} && echo "{{branch}}" > BRANCH');
|
run(RELEASE_CD . 'echo "{{branch}}" > BRANCH');
|
||||||
run('cd {{release_path}} && date -u +"%Y-%m-%dT%H:%M:%SZ" > DEPLOYED_AT');
|
run(RELEASE_CD . 'date -u +"%Y-%m-%dT%H:%M:%SZ" > DEPLOYED_AT');
|
||||||
});
|
});
|
||||||
|
|
||||||
task('artisan:clear', function (): void {
|
task('artisan:clear', function (): void {
|
||||||
run('cd {{release_path}} && php artisan view:clear');
|
run(RELEASE_CD . 'php artisan view:clear');
|
||||||
run('cd {{release_path}} && php artisan optimize:clear');
|
run(RELEASE_CD . 'php artisan optimize:clear');
|
||||||
run('cd {{release_path}} && php artisan config:clear');
|
run(RELEASE_CD . 'php artisan config:clear');
|
||||||
run('cd {{release_path}} && php artisan route:clear');
|
run(RELEASE_CD . 'php artisan route:clear');
|
||||||
});
|
});
|
||||||
|
|
||||||
task('services:restart', function (): void {
|
task('services:restart', function (): void {
|
||||||
run('sudo -n nginx -t');
|
run('sudo -n nginx -t');
|
||||||
run('sudo -n systemctl reload nginx');
|
run('sudo -n systemctl reload nginx');
|
||||||
run('sudo -n systemctl restart php8.3-fpm');
|
run('sudo -n systemctl restart php8.4-fpm');
|
||||||
});
|
});
|
||||||
|
|
||||||
after('deploy:update_code', 'deploy:write_revision_file');
|
after('deploy:update_code', 'deploy:write_revision_file');
|
||||||
after('deploy:vendors', 'build');
|
after('deploy:vendors', 'build');
|
||||||
after('deploy:symlink', 'artisan:clear');
|
after(DEPLOY_SYMLINK, 'artisan:clear');
|
||||||
after('deploy:symlink', 'queue:restart');
|
after(DEPLOY_SYMLINK, 'queue:restart');
|
||||||
after('deploy:failed', 'deploy:unlock');
|
after('deploy:failed', 'deploy:unlock');
|
||||||
after('deploy:symlink', 'services:restart');
|
after(DEPLOY_SYMLINK, 'services:restart');
|
||||||
|
|||||||
@@ -3,6 +3,5 @@ PATH="/opt/homebrew/opt/openjdk/bin:$PATH" \
|
|||||||
sonar-scanner \
|
sonar-scanner \
|
||||||
-Dsonar.projectKey=Warehouse-Management-System \
|
-Dsonar.projectKey=Warehouse-Management-System \
|
||||||
-Dsonar.sources=. \
|
-Dsonar.sources=. \
|
||||||
-Dsonar.branch.name=stage \
|
|
||||||
-Dsonar.host.url=http://192.168.1.2:9001 \
|
-Dsonar.host.url=http://192.168.1.2:9001 \
|
||||||
-Dsonar.login=sqp_4c20c01cef71e0a3d02c184a21625dd73d5f7362
|
-Dsonar.login=sqp_4c20c01cef71e0a3d02c184a21625dd73d5f7362
|
||||||
|
|||||||
Reference in New Issue
Block a user