|
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
|
|
|
abstract class FrameworkTemplate extends Template |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* {@inheritDoc} |
|
14
|
|
|
*/ |
|
15
|
|
|
protected function getTemplateContent() |
|
16
|
|
|
{ |
|
17
|
|
|
return <<<PHP |
|
18
|
|
|
<?php |
|
19
|
|
|
namespace Deployer; |
|
20
|
|
|
require 'recipe/{$this->getRecipe()}.php'; |
|
21
|
|
|
|
|
22
|
|
|
// Configuration |
|
23
|
|
|
|
|
24
|
|
|
set('ssh_type', 'native'); |
|
25
|
|
|
set('ssh_multiplexing', true); |
|
26
|
|
|
|
|
27
|
|
|
set('repository', '[email protected]:username/repository.git'); |
|
28
|
|
|
|
|
29
|
|
|
add('shared_files', []); |
|
30
|
|
|
add('shared_dirs', []); |
|
31
|
|
|
|
|
32
|
|
|
add('writable_dirs', []); |
|
33
|
|
|
|
|
34
|
|
|
// Servers |
|
35
|
|
|
|
|
36
|
|
|
server('production', 'domain.com') |
|
37
|
|
|
->user('username') |
|
38
|
|
|
->identityFile() |
|
39
|
|
|
->set('deploy_path', '/var/www/domain.com') |
|
40
|
|
|
->pty(true); |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
// Tasks |
|
44
|
|
|
|
|
45
|
|
|
desc('Restart PHP-FPM service'); |
|
46
|
|
|
task('php-fpm:restart', function () { |
|
47
|
|
|
// The user must have rights for restart service |
|
48
|
|
|
// /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service |
|
49
|
|
|
run('sudo systemctl restart php-fpm.service'); |
|
50
|
|
|
}); |
|
51
|
|
|
after('deploy:symlink', 'php-fpm:restart'); |
|
52
|
|
|
|
|
53
|
|
|
// [Optional] if deploy fails automatically unlock. |
|
54
|
|
|
after('deploy:failed', 'deploy:unlock'); |
|
55
|
|
|
{$this->getExtraContent()} |
|
56
|
|
|
PHP; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
abstract protected function getRecipe(); |
|
60
|
|
|
|
|
61
|
|
|
protected function getExtraContent() |
|
62
|
|
|
{ |
|
63
|
|
|
return ''; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|