forked from youyingxiang/Discover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.php
103 lines (86 loc) · 2.95 KB
/
deploy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/*
* // +----------------------------------------------------------------------
* // | erp
* // +----------------------------------------------------------------------
* // | Copyright (c) 2006~2020 erp All rights reserved.
* // +----------------------------------------------------------------------
* // | Licensed ( LICENSE-1.0.0 )
* // +----------------------------------------------------------------------
* // | Author: yxx <[email protected]>
* // +----------------------------------------------------------------------
*/
namespace Deployer;
require 'recipe/laravel.php';
// Project name
set('application', 'hzerp');
// Project repository
set('repository', '[email protected]:yxx2017/hzerp.git');
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', false);
//set('default_stage', 'master');
// Shared files/dirs between deploys
add('shared_files', []);
add('shared_dirs', ['public/uploads']);
// Writable dirs by web server
add('writable_dirs', []);
set('allow_anonymous_stats', false);
set('writable_use_sudo', false);
// Hosts
set('keep_releases', 5);
set('default_stage', 'dev');
host('dev')
->stage('dev')
->hostname('118.178.125.242')
->user('deployer')
// 并指定公钥的位置
->identityFile('~/.ssh/deployerkey')
->set('branch', 'master')
->set('http_user', 'nginx')
->forwardAgent(true)
->multiplexing(true)
// 指定项目部署到服务器上的哪个目录
->set('deploy_path', '/data/wwwroot/erp');
host('yxx')
->stage('yxx')
->hostname('47.106.87.22')
->user('deployer')
// 并指定公钥的位置
->identityFile('~/.ssh/deployerkey')
->set('branch', 'master')
->set('http_user', 'www-data')
->forwardAgent(true)
->multiplexing(true)
// 指定项目部署到服务器上的哪个目录
->set('deploy_path', '/data/wwwroot/erp');
task('artisan:cache:clear', function () {
return true;
});
task('artisan:config:cache', function () {
return true;
});
task('artisan:route:cache', function () {
return true;
});
task('artisan:view:cache', function () {
return true;
});
task('opcache:reload', function () {
cd('{{release_path}}');
// run('{{bin/php}} artisan optimize && {{bin/composer}} dump-autoload --optimize && {{bin/php}} artisan config:clear');
run('{{bin/php}} artisan optimize && {{bin/composer}} dump-autoload --optimize && {{bin/php}} artisan migrate && {{bin/php}} artisan db:seed --class=InitSeeder');
$ret = (int) run('ps -ef |grep -w laravels|grep -v grep|wc -l');
if ($ret > 0) {
run('sudo {{bin/php}} bin/laravels restart -d 1>/dev/null');
} else {
run('sudo /usr/sbin/service php7.4-fpm reload');
}
});
// Tasks
task('build', function () {
run('cd {{release_path}} && build');
});
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
// Migrate database before symlink new release.
before('deploy:symlink', 'opcache:reload');