1
|
|
|
<?php |
2
|
|
|
/* (c) Anton Medvedev <[email protected]> |
3
|
|
|
* |
4
|
|
|
* For the full copyright and license information, please view the LICENSE |
5
|
|
|
* file that was distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Deployer\Initializer\Template; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Generate a common (base) deployer configuration |
12
|
|
|
* |
13
|
|
|
* @author Vitaliy Zhuk <[email protected]> |
14
|
|
|
* @author Anton Medvedev <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class CommonTemplate extends Template |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* {@inheritDoc} |
20
|
|
|
*/ |
21
|
|
|
protected function getTemplateContent() |
22
|
|
|
{ |
23
|
|
|
return <<<PHP |
24
|
|
|
<?php |
25
|
|
|
namespace Deployer; |
26
|
|
|
require 'recipe/common.php'; |
27
|
|
|
|
28
|
|
|
// Configuration |
29
|
|
|
|
30
|
|
|
set('ssh_type', 'native'); |
31
|
|
|
set('ssh_multiplexing', true); |
32
|
|
|
|
33
|
|
|
set('repository', '[email protected]:username/repository.git'); |
34
|
|
|
set('shared_files', []); |
35
|
|
|
set('shared_dirs', []); |
36
|
|
|
set('writable_dirs', []); |
37
|
|
|
|
38
|
|
|
// Servers |
39
|
|
|
|
40
|
|
|
server('production', 'domain.com') |
41
|
|
|
->user('username') |
42
|
|
|
->identityFile() |
43
|
|
|
->set('deploy_path', '/var/www/domain.com'); |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
// Tasks |
47
|
|
|
|
48
|
|
|
desc('Restart PHP-FPM service'); |
49
|
|
|
task('php-fpm:restart', function () { |
50
|
|
|
// The user must have rights for restart service |
51
|
|
|
// /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service |
52
|
|
|
run('sudo systemctl restart php-fpm.service'); |
53
|
|
|
}); |
54
|
|
|
after('deploy:symlink', 'php-fpm:restart'); |
55
|
|
|
|
56
|
|
|
desc('Deploy your project'); |
57
|
|
|
task('deploy', [ |
58
|
|
|
'deploy:prepare', |
59
|
|
|
'deploy:lock', |
60
|
|
|
'deploy:release', |
61
|
|
|
'deploy:update_code', |
62
|
|
|
'deploy:shared', |
63
|
|
|
'deploy:writable', |
64
|
|
|
'deploy:vendors', |
65
|
|
|
'deploy:clear_paths', |
66
|
|
|
'deploy:symlink', |
67
|
|
|
'deploy:unlock', |
68
|
|
|
'cleanup', |
69
|
|
|
'success' |
70
|
|
|
]); |
71
|
|
|
|
72
|
|
|
// [Optional] if deploy fails automatically unlock. |
73
|
|
|
after('deploy:failed', 'deploy:unlock'); |
74
|
|
|
PHP; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|