-
Notifications
You must be signed in to change notification settings - Fork 80
/
envoy.blade.php
108 lines (87 loc) · 2.85 KB
/
envoy.blade.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
104
105
106
107
108
@servers(['airflix' => '[email protected]',])
@setup
$test = 'hola, whatever';
$domain = isset($domain) ? $domain : "airflix.local";
$branch = isset($branch) ? $branch : "master";
$repo = '[email protected]:wells/airflix.git';
$rootDir = '/srv/www';
$appDir = $rootDir . '/' . $domain;
$storageDir = $appDir . '/storage';
$downloadsDir = $appDir . '/downloads';
$releaseDir = $appDir . '/releases';
$appSymlink = $appDir . '/current';
$rollbackSymlink = $appDir . '/rollback';
$release = 'release_' . date('YmdHis');
@endsetup
@task('test', ['on' => 'airflix'])
#test
echo {{ $test }}
@endtask
@task('rollback', ['on' => 'airflix'])
#rollback
if [[ -L {{ $rollbackSymlink }} && -d {{ $rollbackSymlink }} ]]
then
ln -nfs $(readlink {{ $rollbackSymlink }}) {{ $appSymlink }};
rm {{ $rollbackSymlink }};
fi
sudo service php7.0-fpm restart;
sleep 1;
php {{ $appSymlink }}/artisan queue:restart;
@endtask
@task('deploy', ['on' => 'airflix'])
#remove-rollback
if [[ -L {{ $rollbackSymlink }} && -d {{ $rollbackSymlink }} ]]
then
rm -rf $(readlink {{ $rollbackSymlink }});
rm {{ $rollbackSymlink }};
fi
#fetch-package
if [[ ! -d {{ $appDir }} ]]
then
mkdir {{ $appDir }};
chmod ug+rwx {{ $appDir }};
fi
if [[ ! -d {{ $releaseDir }} ]]
then
mkdir {{ $releaseDir }};
chmod ug+rwx {{ $releaseDir }};
fi
cd {{ $releaseDir }};
git clone -b {{ $branch }} --depth=1 {{ $repo }} {{ $release }};
#run-composer
cd {{ $releaseDir }}/{{ $release }};
if [[ ! -d {{ $storageDir }} ]]
then
mv {{ $releaseDir }}/{{ $release }}/storage {{ $storageDir }};
chmod ug+rwx {{ $storageDir }};
fi
if [[ ! -d {{ $downloadsDir }} ]]
then
mv {{ $releaseDir }}/{{ $release }}/public/downloads {{ $downloadsDir }};
chmod ug+rwx {{ $downloadsDir }};
fi
composer install --prefer-dist --no-scripts;
php artisan clear-compiled --env=production;
php artisan optimize --env=production;
php artisan route:cache --env=production;
#update-permissions
cd {{ $releaseDir }};
chmod -R ug+rwx {{ $release }};
#update-symlinks
echo 'Updating symlinks.';
if [[ -L {{ $appSymlink }} ]]
then
cd $appDir;
ln -nfs $(readlink {{ $appSymlink }}) {{ $rollbackSymlink }};
fi
cd {{ $releaseDir }}/{{ $release }};
rm -rf {{ $releaseDir }}/{{ $release }}/storage;
ln -nfs {{ $storageDir }} storage;
rm -rf {{ $releaseDir }}/{{ $release }}/public/downloads;
ln -nfs {{ $appDir }}/downloads public/downloads;
ln -nfs {{ $appDir }}/.env .env;
ln -nfs {{ $releaseDir }}/{{ $release }} {{ $appSymlink }};
sudo service php7.0-fpm restart;
sleep 1;
php {{ $appSymlink }}/artisan queue:restart;
@endtask