80 lines
2.0 KiB
PHP
80 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Deployer;
|
|
|
|
require 'recipe/laravel.php';
|
|
|
|
// Project name
|
|
set('application', 'my_project');
|
|
|
|
// Project repository
|
|
set('repository', 'git@gitee.com:zi-chunsheng-e-commerce/mall-server.git');
|
|
|
|
// [Optional] Allocate tty for git clone. Default value is false.
|
|
set('git_tty', true);
|
|
|
|
// Shared files/dirs between deploys
|
|
add('shared_files', []);
|
|
add('shared_dirs', []);
|
|
|
|
// Writable dirs by web server
|
|
add('writable_dirs', []);
|
|
|
|
|
|
// Hosts
|
|
|
|
host('test.zichunsheng.cn')
|
|
->user('deployer')
|
|
->port(22)
|
|
->identityFile('~/.ssh/deployer_rsa')
|
|
->forwardAgent(true)
|
|
->multiplexing(true)
|
|
->addSshOption('UserKnownHostsFile', '/dev/null')
|
|
->addSshOption('StrictHostKeyChecking', 'no')
|
|
->stage('test')
|
|
->set('branch', 'develop')
|
|
->set('deploy_path', '/www/wwwroot/test.zichunsheng.cn');
|
|
|
|
|
|
// 生产环境
|
|
|
|
host('production')
|
|
->hostname('47.108.202.152')
|
|
->user('deployer')
|
|
->port(22)
|
|
->identityFile('~/.ssh/deployer_rsa')
|
|
->forwardAgent(true)
|
|
->multiplexing(true)
|
|
->addSshOption('UserKnownHostsFile', '/dev/null')
|
|
->addSshOption('StrictHostKeyChecking', 'no')
|
|
->stage('production')
|
|
->set('branch', 'master')
|
|
->set('deploy_path', '/www/wwwroot/api.zichunsheng.cn');
|
|
|
|
host('admin')
|
|
->hostname('47.108.202.152')
|
|
->user('deployer')
|
|
->port(22)
|
|
->identityFile('~/.ssh/deployer_rsa')
|
|
->forwardAgent(true)
|
|
->multiplexing(true)
|
|
->addSshOption('UserKnownHostsFile', '/dev/null')
|
|
->addSshOption('StrictHostKeyChecking', 'no')
|
|
->stage('admin')
|
|
->set('branch', 'master')
|
|
->set('deploy_path', '/www/wwwroot/admin.zichunsheng.cn');
|
|
// Tasks
|
|
|
|
// 如果发布失败,自动解锁
|
|
after('deploy:failed', 'deploy:unlock');
|
|
// 发布完成后重启 PHP-FPM
|
|
after('success', 'php:restart');
|
|
|
|
// Migrate database before symlink new release.
|
|
before('deploy:symlink', 'artisan:migrate');
|
|
|
|
desc('重启 PHP-FPM 进程');
|
|
task('php:restart', function () {
|
|
run('sudo systemctl restart php8.0-fpm.service');
|
|
})->onStage(['production', 'admin']);
|