kstrano 1.0.12 → 1.1.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/kumafy +139 -117
- data/lib/helpers/airbrake_helper.rb +6 -6
- data/lib/helpers/campfire_helper.rb +6 -6
- data/lib/helpers/git_helper.rb +9 -9
- data/lib/helpers/jenkins_helper.rb +25 -25
- data/lib/helpers/kuma_helper.rb +6 -6
- data/lib/kstrano.rb +101 -137
- data/lib/kstrano_drupal.rb +18 -0
- data/lib/kstrano_magento.rb +18 -0
- data/lib/kstrano_play.rb +50 -0
- data/lib/kstrano_symfony2.rb +156 -0
- data/resources/deploy.rb +37 -0
- data/resources/deploy_production.rb +5 -0
- data/resources/deploy_staging.rb +4 -0
- data/resources/play/deploy.rb +2 -0
- data/resources/play/start.sh +14 -0
- data/resources/play/stop.sh +11 -0
- data/resources/symfony2/apcclear.php +9 -0
- data/resources/symfony2/app_test.php +35 -0
- data/resources/symfony2/behat.yml-dist +17 -0
- data/resources/symfony2/build.xml +210 -0
- data/resources/symfony2/deploy.rb +13 -0
- data/resources/symfony2/phpcs.xml +36 -0
- data/resources/symfony2/phpdox.xml +12 -0
- data/resources/symfony2/phpmd.xml +19 -0
- data/resources/symfony2/phpunit.xml.dist +57 -0
- metadata +42 -7
data/lib/kstrano.rb
CHANGED
@@ -1,93 +1,141 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
set :copy_vendors, true
|
1
|
+
require "#{File.dirname(__FILE__)}/helpers/git_helper.rb"
|
2
|
+
require "#{File.dirname(__FILE__)}/helpers/kuma_helper.rb"
|
5
3
|
|
6
|
-
|
7
|
-
|
4
|
+
require 'new_relic/recipes'
|
5
|
+
require 'new_relic/agent'
|
8
6
|
|
9
7
|
set :webserver_user, "www-data"
|
10
8
|
set :permission_method, :acl
|
11
9
|
set :server_name, nil
|
12
10
|
set :port, 22
|
11
|
+
set :shared_files, false
|
12
|
+
set :shared_children, false
|
13
13
|
|
14
|
-
set :dump_assetic_assets, true
|
15
|
-
set :interactive_mode, false
|
16
|
-
set :clear_controllers, false # set this by default to false, because it's quiet dangerous for existing projects. You need to make sure it doesn't delete your app.php
|
17
|
-
|
18
|
-
require "#{File.dirname(__FILE__)}/helpers/git_helper.rb"
|
19
|
-
require "#{File.dirname(__FILE__)}/helpers/kuma_helper.rb"
|
20
|
-
require 'rexml/document'
|
21
|
-
require 'etc'
|
22
|
-
require 'new_relic/recipes'
|
23
|
-
require 'new_relic/agent'
|
24
14
|
|
25
15
|
namespace :files do
|
26
16
|
namespace :move do
|
27
17
|
|
28
18
|
desc "Rsync uploaded files from online to local"
|
29
19
|
task :to_local do
|
30
|
-
|
31
|
-
log = `rsync -qazhL --progress --del --rsh=/usr/bin/ssh -e "ssh -p #{port}" --exclude "*bak" --exclude "*~" --exclude ".*" #{domain}:#{current_path}
|
32
|
-
|
20
|
+
KStrano.say "Copying files"
|
21
|
+
log = `rsync -qazhL --progress --del --rsh=/usr/bin/ssh -e "ssh -p #{port}" --exclude "*bak" --exclude "*~" --exclude ".*" #{domain}:#{current_path}/#{uploaded_files_path}/* #{uploaded_files_path}/`
|
22
|
+
KStrano.say log
|
33
23
|
end
|
34
24
|
|
35
25
|
end
|
36
26
|
end
|
37
27
|
|
38
|
-
namespace :
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
28
|
+
namespace :kuma do
|
29
|
+
|
30
|
+
# modified version from capifony
|
31
|
+
desc "Symlinks static directories and static files that need to remain between deployments"
|
32
|
+
task :share_childs, :roles => :app, :except => { :no_release => true } do
|
33
|
+
if shared_children
|
34
|
+
shared_children.each do |link|
|
35
|
+
run "#{try_sudo} mkdir -p #{shared_path}/#{link}"
|
36
|
+
run "#{try_sudo} sh -c 'if [ -d #{release_path}/#{link} ] ; then rm -rf #{release_path}/#{link}; fi'"
|
37
|
+
run "#{try_sudo} ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
if shared_files
|
42
|
+
shared_files.each do |link|
|
43
|
+
link_dir = File.dirname("#{shared_path}/#{link}")
|
44
|
+
run "#{try_sudo} mkdir -p #{link_dir}"
|
45
|
+
run "#{try_sudo} touch #{shared_path}/#{link}"
|
46
|
+
run "#{try_sudo} ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
|
47
|
+
end
|
44
48
|
end
|
45
49
|
end
|
46
|
-
end
|
47
50
|
|
48
|
-
|
51
|
+
# modified version from capifony
|
52
|
+
desc "Sets permissions for writable_dirs folders as described in the Symfony documentation"
|
53
|
+
task :set_permissions, :roles => :app, :except => { :no_release => true } do
|
54
|
+
if writable_dirs && permission_method
|
55
|
+
dirs = []
|
49
56
|
|
50
|
-
|
57
|
+
writable_dirs.each do |link|
|
58
|
+
if shared_children && shared_children.include?(link)
|
59
|
+
absolute_link = shared_path + "/" + link
|
60
|
+
else
|
61
|
+
absolute_link = latest_release + "/" + link
|
62
|
+
end
|
51
63
|
|
52
|
-
|
53
|
-
|
54
|
-
end
|
64
|
+
dirs << absolute_link
|
65
|
+
end
|
55
66
|
|
56
|
-
|
57
|
-
|
67
|
+
methods = {
|
68
|
+
:chmod => [
|
69
|
+
"chmod +a \"#{user} allow delete,write,append,file_inherit,directory_inherit\" %s",
|
70
|
+
"chmod +a \"#{webserver_user} allow delete,write,append,file_inherit,directory_inherit\" %s"
|
71
|
+
],
|
72
|
+
:acl => [
|
73
|
+
"setfacl -R -m u:#{user}:rwX -m u:#{webserver_user}:rwX %s",
|
74
|
+
"setfacl -dR -m u:#{user}:rwx -m u:#{webserver_user}:rwx %s"
|
75
|
+
],
|
76
|
+
:chown => ["chown #{webserver_user} %s"]
|
77
|
+
}
|
78
|
+
|
79
|
+
if methods[permission_method]
|
80
|
+
if fetch(:use_sudo, false)
|
81
|
+
methods[permission_method].each do |cmd|
|
82
|
+
sudo sprintf(cmd, dirs.join(' '))
|
83
|
+
end
|
84
|
+
elsif permission_method == :chown
|
85
|
+
puts " You can't use chown method without sudoing"
|
86
|
+
else
|
87
|
+
dirs.each do |dir|
|
88
|
+
is_owner = (capture "`echo stat #{dir} -c %U`").chomp == user
|
89
|
+
if is_owner && permission_method != :chown
|
90
|
+
methods[permission_method].each do |cmd|
|
91
|
+
try_sudo sprintf(cmd, dir)
|
92
|
+
end
|
93
|
+
else
|
94
|
+
puts " #{dir} is not owned by #{user} or you are using 'chown' method without ':use_sudo'"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
else
|
99
|
+
puts " Permission method '#{permission_method}' does not exist.".yellow
|
100
|
+
end
|
58
101
|
end
|
59
|
-
|
60
102
|
end
|
61
103
|
|
62
104
|
desc "Show log of what changed compared to the deployed version"
|
63
105
|
task :changelog do
|
64
106
|
if releases.length > 0
|
65
|
-
|
107
|
+
KStrano::GitHelper.fetch
|
66
108
|
changelog = `git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --no-merges #{current_revision.strip}..#{real_revision.strip}`
|
67
109
|
|
68
110
|
if current_revision.strip == real_revision.strip && changelog.strip.empty?
|
69
111
|
changelog = "No changes found!"
|
70
112
|
end
|
71
113
|
|
72
|
-
|
73
|
-
|
114
|
+
KStrano.say "Changelog of what will be deployed to #{domain}"
|
115
|
+
KStrano.say changelog, ''
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
namespace :ssh_socket do
|
120
|
+
task :fix do
|
121
|
+
sudo "chmod 777 -R `dirname $SSH_AUTH_SOCK`"
|
122
|
+
end
|
123
|
+
task :unfix do
|
124
|
+
sudo "chmod 775 -R `dirname $SSH_AUTH_SOCK`"
|
74
125
|
end
|
75
126
|
end
|
76
127
|
|
77
128
|
|
78
129
|
namespace :sync do
|
79
|
-
|
80
130
|
desc "sync the database and rsync the files"
|
81
131
|
task :to_local do
|
82
132
|
files.move.to_local
|
83
|
-
|
133
|
+
KStrano.say "Copying database"
|
84
134
|
database.move.to_local
|
85
135
|
end
|
86
|
-
|
87
136
|
end
|
88
137
|
|
89
138
|
namespace :fix do
|
90
|
-
|
91
139
|
desc "Run fixcron for the current project"
|
92
140
|
task :cron do
|
93
141
|
sudo "sh -c 'if [ -f /opt/kDeploy/tools/fixcron.py ] ; then cd /opt/kDeploy/tools/; python fixcron.py #{application}; fi'"
|
@@ -97,51 +145,10 @@ namespace :kuma do
|
|
97
145
|
task :perms do
|
98
146
|
sudo "sh -c 'if [ -f /opt/kDeploy/tools/fixperms.py ] ; then cd /opt/kDeploy/tools/; python fixperms.py #{application}; fi'"
|
99
147
|
end
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
namespace :fpm do
|
104
|
-
|
105
|
-
desc "Reload PHP5 fpm"
|
106
|
-
task :reload do
|
107
|
-
sudo "/etc/init.d/php5-fpm reload"
|
108
|
-
end
|
109
|
-
|
110
|
-
desc "Restart PHP5 fpm"
|
111
|
-
task :restart do
|
112
|
-
sudo "/etc/init.d/php5-fpm restart"
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
namespace :apc do
|
118
|
-
|
119
|
-
desc "Prepare for APC cache clear"
|
120
|
-
task :prepare_clear do
|
121
|
-
server_project_name = "#{server_name}"
|
122
|
-
if server_project_name.nil? || server_project_name.empty?
|
123
|
-
server_project_name = domain.split('.')[0]
|
124
|
-
end
|
125
|
-
sudo "sh -c 'if [ ! -f /home/projects/#{server_project_name}/site/apcclear.php ]; then curl https://raw.github.com/Kunstmaan/kStrano/master/config/apcclear.php > /home/projects/#{server_project_name}/site/apcclear.php; fi'"
|
126
|
-
sudo "chmod 777 /home/projects/#{server_project_name}/site/apcclear.php"
|
127
|
-
end
|
128
|
-
|
129
|
-
desc "Clear the APC cache"
|
130
|
-
task :clear do
|
131
|
-
hostname = "#{domain}"
|
132
|
-
server_project_name = "#{server_name}"
|
133
|
-
if !server_project_name.nil? && !server_project_name.empty?
|
134
|
-
hostname = "#{server_project_name}.#{hostname}"
|
135
|
-
end
|
136
|
-
sudo "curl http://#{hostname}/apcclear.php"
|
137
|
-
end
|
138
|
-
|
139
148
|
end
|
140
|
-
|
141
149
|
end
|
142
150
|
|
143
151
|
namespace :deploy do
|
144
|
-
|
145
152
|
task :create_symlink, :except => { :no_release => true } do
|
146
153
|
on_rollback do
|
147
154
|
if previous_release
|
@@ -152,53 +159,20 @@ namespace :deploy do
|
|
152
159
|
end
|
153
160
|
try_sudo "ln -sfT #{latest_release} #{current_path}"
|
154
161
|
end
|
155
|
-
|
156
|
-
desc "Deploy and run pending migrations"
|
157
|
-
task :migrations, :roles => :app, :except => { :no_release => true }, :only => { :primary => true } do
|
158
|
-
set :force_migrations, true
|
159
|
-
deploy.update
|
160
|
-
deploy.restart
|
161
|
-
end
|
162
|
-
|
163
|
-
desc "Deploy without copying the vendors from a previous install"
|
164
|
-
task :clean, :roles => :app, :except => { :no_release => true } do
|
165
|
-
set :copy_vendors, false
|
166
|
-
deploy.update
|
167
|
-
deploy.restart
|
168
|
-
end
|
169
|
-
|
170
|
-
namespace :prefer do
|
171
|
-
|
172
|
-
desc "Deploy without copying the vendors from a previous install and use composer option --prefer-source"
|
173
|
-
task :source, :roles => :app, :except => { :no_release => true } do
|
174
|
-
set :composer_options, "--no-scripts --verbose --prefer-source --optimize-autoloader"
|
175
|
-
deploy.clean
|
176
|
-
end
|
177
|
-
|
178
|
-
end
|
179
|
-
|
180
|
-
namespace :schema do
|
181
|
-
|
182
|
-
desc "Deploy and update the schema"
|
183
|
-
task :update, :roles => :app, :except => { :no_release => true }, :only => { :primary => true } do
|
184
|
-
set :force_schema, true
|
185
|
-
deploy.update
|
186
|
-
deploy.restart
|
187
|
-
end
|
188
|
-
|
189
|
-
end
|
190
|
-
|
191
162
|
end
|
192
163
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
164
|
+
namespace :frontend do
|
165
|
+
namespace :npm do
|
166
|
+
desc "Install the node modules"
|
167
|
+
task :install do
|
168
|
+
run "#{try_sudo} -i sh -c 'cd #{latest_release} && npm install'"
|
198
169
|
end
|
170
|
+
end
|
199
171
|
|
200
|
-
|
201
|
-
|
172
|
+
namespace :bower do
|
173
|
+
desc "Install the javascript vendors"
|
174
|
+
task :install do
|
175
|
+
run "#{try_sudo} -i sh -c 'cd #{latest_release} && bower install'"
|
202
176
|
end
|
203
177
|
end
|
204
178
|
end
|
@@ -217,11 +191,6 @@ after "symfony:composer:update", "kuma:ssh_socket:unfix"
|
|
217
191
|
after "symfony:composer:install", "kuma:ssh_socket:unfix"
|
218
192
|
after "symfony:composer:dump_autoload", "kuma:ssh_socket:unfix"
|
219
193
|
|
220
|
-
# set the right permissions on the vendor folder ...
|
221
|
-
after "symfony:composer:copy_vendors" do
|
222
|
-
sudo "sh -c 'if [ -d #{latest_release}/vendor ] ; then chown -R #{application}:#{application} #{latest_release}/vendor; fi'"
|
223
|
-
end
|
224
|
-
|
225
194
|
# Before update_code:
|
226
195
|
## Make the cached_copy readable for the current user
|
227
196
|
before "deploy:update_code" do
|
@@ -239,21 +208,16 @@ end
|
|
239
208
|
## Fix the permissions of the latest release, so that it's readable for the project user
|
240
209
|
before "deploy:finalize_update" do
|
241
210
|
on_rollback { sudo "rm -rf #{release_path}; true" } # by default capistrano will use the run command, but everything has project user rights in our server setup, so use try_sudo in stead of run.
|
242
|
-
sudo "sh -c 'if [ ! -f #{release_path}/app/config/parameters.ini ] && [ ! -f #{release_path}/app/config/parameters.yml ] ; then if [ -f #{release_path}/paramDecode ] ; then chmod -R ug+rx #{latest_release}/paramDecode && cd #{release_path} && ./paramDecode; elif [ -f #{release_path}/param ] ; then chmod -R ug+rx #{latest_release}/param && cd #{release_path} && ./param decode; fi; fi'"
|
243
211
|
sudo "chown -R #{application}:#{application} #{latest_release}"
|
244
212
|
sudo "setfacl -R -m group:admin:rwx #{latest_release}"
|
245
213
|
end
|
246
214
|
|
247
|
-
before "deploy:finalize_update", "kuma:apc:prepare_clear"
|
248
|
-
after "deploy:finalize_update", "kuma:apc:clear"
|
249
|
-
after "deploy:create_symlink", "kuma:apc:clear"
|
250
|
-
|
251
215
|
before "deploy:update" do
|
252
|
-
|
216
|
+
KStrano.say "executing ssh-add"
|
253
217
|
%x(ssh-add)
|
254
218
|
|
255
219
|
kuma.changelog
|
256
|
-
if !
|
220
|
+
if !KStrano.ask "Are you sure you want to continue deploying?", "y"
|
257
221
|
exit
|
258
222
|
end
|
259
223
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module KStrano
|
2
|
+
module Drupal
|
3
|
+
def self.load_into(configuration)
|
4
|
+
configuration.load do
|
5
|
+
|
6
|
+
load_paths.push File.expand_path('../', __FILE__)
|
7
|
+
load 'kstrano'
|
8
|
+
|
9
|
+
## Custom stuff here
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
if Capistrano::Configuration.instance
|
17
|
+
KStrano::Drupal.load_into(Capistrano::Configuration.instance)
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module KStrano
|
2
|
+
module Magento
|
3
|
+
def self.load_into(configuration)
|
4
|
+
configuration.load do
|
5
|
+
|
6
|
+
load_paths.push File.expand_path('../', __FILE__)
|
7
|
+
load 'kstrano'
|
8
|
+
|
9
|
+
## Custom stuff here
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
if Capistrano::Configuration.instance
|
17
|
+
KStrano::Magento.load_into(Capistrano::Configuration.instance)
|
18
|
+
end
|
data/lib/kstrano_play.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'railsless-deploy'
|
2
|
+
|
3
|
+
module KStrano
|
4
|
+
module Play
|
5
|
+
def self.load_into(configuration)
|
6
|
+
configuration.load do
|
7
|
+
|
8
|
+
load_paths.push File.expand_path('../', __FILE__)
|
9
|
+
load 'kstrano'
|
10
|
+
|
11
|
+
namespace :deploy do
|
12
|
+
desc "Updates latest release source path"
|
13
|
+
task :finalize_update, :roles => :app, :except => { :no_release => true } do
|
14
|
+
run "#{try_sudo} chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
|
15
|
+
run "#{try_sudo} chmod u+rx #{latest_release}/start.sh"
|
16
|
+
run "#{try_sudo} chmod u+rx #{latest_release}/stop.sh"
|
17
|
+
|
18
|
+
kuma::share_childs
|
19
|
+
|
20
|
+
play::package
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
namespace :play do
|
25
|
+
desc "Build the app"
|
26
|
+
task :package do
|
27
|
+
try_sudo "bash -c 'PATH=$PATH:/home/projects/#{application}/play/default:. && cd #{latest_release} && play clean compile stage'"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Start the server"
|
31
|
+
task :start do
|
32
|
+
try_sudo "bash -ic 'cd #{current_path} && PLAY_ENV=#{env} ./start.sh'"
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Stop the server"
|
36
|
+
task :stop do
|
37
|
+
try_sudo "bash -c 'cd #{current_path} && ./stop.sh'"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
after "deploy", "play:stop", "play:start"
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
if Capistrano::Configuration.instance
|
49
|
+
KStrano::Play.load_into(Capistrano::Configuration.instance)
|
50
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require 'railsless-deploy'
|
2
|
+
require 'capifony_symfony2'
|
3
|
+
require "#{File.dirname(__FILE__)}/helpers/kuma_helper.rb"
|
4
|
+
|
5
|
+
module KStrano
|
6
|
+
module Symfony2
|
7
|
+
def self.load_into(configuration)
|
8
|
+
configuration.load do
|
9
|
+
|
10
|
+
load_paths.push File.expand_path('../', __FILE__)
|
11
|
+
load 'kstrano'
|
12
|
+
|
13
|
+
set :php_bin, "php"
|
14
|
+
|
15
|
+
set :copy_vendors, true
|
16
|
+
|
17
|
+
set :force_schema, false
|
18
|
+
set :force_migrations, false
|
19
|
+
|
20
|
+
set :dump_assetic_assets, true
|
21
|
+
set :interactive_mode, false
|
22
|
+
set :clear_controllers, false # set this by default to false, because it's quiet dangerous for existing projects. You need to make sure it doesn't delete your app.php
|
23
|
+
|
24
|
+
set (:symfony_env_prod) {"#{env}"}
|
25
|
+
|
26
|
+
set :uploaded_files_path, 'web/uploads'
|
27
|
+
|
28
|
+
set :npm_install, true
|
29
|
+
set :bower_install, true
|
30
|
+
|
31
|
+
namespace :database do
|
32
|
+
namespace :move do
|
33
|
+
desc "DISABLED"
|
34
|
+
task :to_remote, :roles => :db, :only => { :primary => true } do
|
35
|
+
KStrano.say "This feature is DISABLED!"
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
namespace :kuma do
|
42
|
+
namespace :fpm do
|
43
|
+
desc "Reload PHP5 fpm"
|
44
|
+
task :reload do
|
45
|
+
sudo "/etc/init.d/php5-fpm reload"
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "Restart PHP5 fpm"
|
49
|
+
task :restart do
|
50
|
+
sudo "/etc/init.d/php5-fpm restart"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
namespace :apc do
|
55
|
+
desc "Prepare for APC cache clear"
|
56
|
+
task :prepare_clear do
|
57
|
+
server_project_name = "#{server_name}"
|
58
|
+
if server_project_name.nil? || server_project_name.empty?
|
59
|
+
server_project_name = domain.split('.')[0]
|
60
|
+
end
|
61
|
+
sudo "sh -c 'if [ ! -f /home/projects/#{server_project_name}/site/apcclear.php ]; then curl https://raw.github.com/Kunstmaan/kStrano/master/config/apcclear.php > /home/projects/#{server_project_name}/site/apcclear.php; fi'"
|
62
|
+
sudo "chmod 777 /home/projects/#{server_project_name}/site/apcclear.php"
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Clear the APC cache"
|
66
|
+
task :clear do
|
67
|
+
hostname = "#{domain}"
|
68
|
+
server_project_name = "#{server_name}"
|
69
|
+
if !server_project_name.nil? && !server_project_name.empty?
|
70
|
+
hostname = "#{server_project_name}.#{hostname}"
|
71
|
+
end
|
72
|
+
sudo "curl http://#{hostname}/apcclear.php"
|
73
|
+
sudo "pkill -QUIT -e -f \"^php-fpm: pool #{application} \" "
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
namespace :deploy do
|
79
|
+
desc "Deploy and run pending migrations"
|
80
|
+
task :migrations, :roles => :app, :except => { :no_release => true }, :only => { :primary => true } do
|
81
|
+
set :force_migrations, true
|
82
|
+
deploy.update
|
83
|
+
deploy.restart
|
84
|
+
end
|
85
|
+
|
86
|
+
desc "Deploy without copying the vendors from a previous install"
|
87
|
+
task :clean, :roles => :app, :except => { :no_release => true } do
|
88
|
+
set :copy_vendors, false
|
89
|
+
deploy.update
|
90
|
+
deploy.restart
|
91
|
+
end
|
92
|
+
|
93
|
+
namespace :prefer do
|
94
|
+
desc "Deploy without copying the vendors from a previous install and use composer option --prefer-source"
|
95
|
+
task :source, :roles => :app, :except => { :no_release => true } do
|
96
|
+
set :composer_options, "--no-scripts --verbose --prefer-source --optimize-autoloader"
|
97
|
+
deploy.clean
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
namespace :schema do
|
103
|
+
desc "Deploy and update the schema"
|
104
|
+
task :update, :roles => :app, :except => { :no_release => true }, :only => { :primary => true } do
|
105
|
+
set :force_schema, true
|
106
|
+
deploy.update
|
107
|
+
deploy.restart
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# make it possible to run schema:update and migrations:migrate at the right place in the flow
|
113
|
+
after "symfony:bootstrap:build" do
|
114
|
+
if model_manager == "doctrine"
|
115
|
+
if force_schema
|
116
|
+
symfony.doctrine.schema.update
|
117
|
+
end
|
118
|
+
|
119
|
+
if force_migrations
|
120
|
+
symfony.doctrine.migrations.migrate
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# set the right permissions on the vendor folder ...
|
126
|
+
after "symfony:composer:copy_vendors" do
|
127
|
+
sudo "sh -c 'if [ -d #{latest_release}/vendor ] ; then chown -R #{application}:#{application} #{latest_release}/vendor; fi'"
|
128
|
+
end
|
129
|
+
|
130
|
+
before "deploy:finalize_update" do
|
131
|
+
sudo "sh -c 'if [ ! -f #{release_path}/app/config/parameters.ini ] && [ ! -f #{release_path}/app/config/parameters.yml ] ; then if [ -f #{release_path}/paramDecode ] ; then chmod -R ug+rx #{latest_release}/paramDecode && cd #{release_path} && ./paramDecode; elif [ -f #{release_path}/param ] ; then chmod -R ug+rx #{latest_release}/param && cd #{release_path} && ./param decode; fi; fi'"
|
132
|
+
end
|
133
|
+
|
134
|
+
["symfony:composer:install", "symfony:composer:update", "symfony:vendors:install", "symfony:vendors:upgrade"].each do |action|
|
135
|
+
after action do |variable|
|
136
|
+
if npm_install
|
137
|
+
end
|
138
|
+
|
139
|
+
if bower_install
|
140
|
+
frontend.bower.install
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
before "deploy:finalize_update", "kuma:apc:prepare_clear"
|
146
|
+
after "deploy:finalize_update", "kuma:apc:clear"
|
147
|
+
after "deploy:create_symlink", "kuma:apc:clear"
|
148
|
+
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
if Capistrano::Configuration.instance
|
155
|
+
KStrano::Symfony2.load_into(Capistrano::Configuration.instance)
|
156
|
+
end
|
data/resources/deploy.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Main
|
2
|
+
set :application, ""
|
3
|
+
set :use_sudo, true
|
4
|
+
set :admin_runner, ""
|
5
|
+
set :keep_releases, 5
|
6
|
+
default_run_options[:pty] = true
|
7
|
+
|
8
|
+
# Stages
|
9
|
+
set :stage_dir, ""
|
10
|
+
set :stages, %w{production staging}
|
11
|
+
set :default_stage, "production"
|
12
|
+
require 'capistrano/ext/multistage'
|
13
|
+
|
14
|
+
set :deploy_to, "/home/projects/#{application}/data/"
|
15
|
+
set (:domain) {"#{domain}"} # domain is defined in the stage config
|
16
|
+
|
17
|
+
role(:web) { domain } # Your HTTP server, Apache/etc
|
18
|
+
role(:app, :primary => true) { domain } # This may be the same as your `Web` server
|
19
|
+
role(:db, :primary => true) { domain } # This is where the migrations will run
|
20
|
+
|
21
|
+
# Git
|
22
|
+
set :repository, `git config remote.origin.url`.strip # fetch the repository from git
|
23
|
+
set :scm, :git
|
24
|
+
ssh_options[:forward_agent] = true # http://help.github.com/deploy-with-capistrano/
|
25
|
+
set :deploy_via, :remote_cache #only keeps an online cache
|
26
|
+
set :branch, "master"
|
27
|
+
|
28
|
+
set :newrelic_appname, "" # The name of the application in newrelic
|
29
|
+
set :newrelic_license_key, "" # The license key can be found under 'Account settings'
|
30
|
+
|
31
|
+
# Logging
|
32
|
+
# - IMPORTANT = 0
|
33
|
+
# - INFO = 1
|
34
|
+
# - DEBUG = 2
|
35
|
+
# - TRACE = 3
|
36
|
+
# - MAX_LEVEL = 3
|
37
|
+
logger.level = Logger::MAX_LEVEL
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
if [ -z "$PLAY_ENV" ]; then
|
4
|
+
PLAY_ENV="prod"
|
5
|
+
fi
|
6
|
+
|
7
|
+
START_PARAMETERS="-Dpidfile.path=./pids/play.pid -Dconfig.resource=$PLAY_ENV.conf -Dlogger.resource=$PLAY_ENV-logger.xml"
|
8
|
+
if [ -f "newrelic/newrelic.jar" ]; then
|
9
|
+
START_PARAMETERS="$START_PARAMETERS -javaagent:newrelic/newrelic.jar -Dnewrelic.bootstrap_classpath=true"
|
10
|
+
else
|
11
|
+
echo "no newrelic.jar file found!"
|
12
|
+
fi
|
13
|
+
|
14
|
+
nohup bash -c "target/start $START_PARAMETERS $* &>> ./logs/$PLAY_ENV.log" &
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<?php
|
2
|
+
if (in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1', @$_SERVER['SERVER_ADDR']))) {
|
3
|
+
apc_clear_cache();
|
4
|
+
apc_clear_cache('user');
|
5
|
+
apc_clear_cache('opcode');
|
6
|
+
echo json_encode(array('success' => true));
|
7
|
+
} else {
|
8
|
+
die('SUPER TOP SECRET');
|
9
|
+
}
|