kstrano 0.0.29 → 0.0.30

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/kumafy +7 -1
  2. data/lib/kstrano.rb +102 -76
  3. metadata +7 -39
data/bin/kumafy CHANGED
@@ -16,7 +16,9 @@ STAGING_GIST = "https://raw.github.com/Kunstmaan/kStrano/master/config/staging.r
16
16
  BUILD_GIST = "https://raw.github.com/Kunstmaan/kStrano/master/config/build.xml"
17
17
  PHPCS_GIST = "https://raw.github.com/Kunstmaan/kStrano/master/config/phpcs.xml"
18
18
  PHPMD_GIST = "https://raw.github.com/Kunstmaan/kStrano/master/config/phpmd.xml"
19
+ PHPDOX_GIST = "https://raw.github.com/Kunstmaan/kStrano/master/config/phpdox.xml"
19
20
  PHPUNIT_GIST = "https://raw.github.com/Kunstmaan/kStrano/master/config/phpunit.xml.dist"
21
+ APPTEST_GIST = "https://raw.github.com/Kunstmaan/kStrano/master/config/app_test.php"
20
22
 
21
23
  def update_capfile(base, context, force)
22
24
  file = File.join(base, "Capfile")
@@ -129,12 +131,16 @@ def update_jenkins_config(ui, base, context, force)
129
131
  end
130
132
 
131
133
  build_dir = File.join(base, "build")
134
+ web_dir = File.join(base, "web")
132
135
  Dir.mkdir(build_dir) unless File.directory?(build_dir)
136
+ Dir.mkdir(web_dir) unless File.directory?(web_dir)
133
137
 
134
138
  {
135
139
  File.join(build_dir, "phpcs.xml") => PHPCS_GIST,
136
140
  File.join(build_dir, "phpmd.xml") => PHPMD_GIST,
137
- File.join(base, "app", "phpunit.xml.dist") => PHPUNIT_GIST
141
+ File.join(build_dir, "phpdox.xml") => PHPDOX_GIST,
142
+ File.join(base, "app", "phpunit.xml.dist") => PHPUNIT_GIST,
143
+ File.join(web_dir, "app_test.php") => APPTEST_GIST
138
144
  }.each do |file, gist|
139
145
  write = true
140
146
 
data/lib/kstrano.rb CHANGED
@@ -1,9 +1,20 @@
1
1
  # PHP binary to execute
2
2
  set :php_bin, "php"
3
- # Symfony console bin
4
- set :symfony_console, app_path + "/console"
3
+
4
+ set :copy_vendors, true
5
5
 
6
6
  set :force_schema, false
7
+ set :force_migrations, false
8
+
9
+ set :webserver_user, "www-data"
10
+ set :permission_method, :acl
11
+
12
+ set :dump_assetic_assets, true
13
+ set :interactive_mode, true
14
+ 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
15
+
16
+ # http://getcomposer.org/doc/03-cli.md
17
+ set :composer_options, "--no-scripts --verbose --prefer-dist --optimize-autoloader"
7
18
 
8
19
  require "#{File.dirname(__FILE__)}/helpers/git_helper.rb"
9
20
  require "#{File.dirname(__FILE__)}/helpers/kuma_helper.rb"
@@ -12,42 +23,56 @@ require 'etc'
12
23
 
13
24
  namespace :kuma do
14
25
 
15
- desc "Run fixcron for the current project"
16
- task :fixcron do
17
- sudo "sh -c 'if [ -f /opt/kDeploy/tools/fixcron.py ] ; then cd /opt/kDeploy/tools/; python fixcron.py #{application}; fi'"
18
- end
26
+ namespace :ssh_socket do
19
27
 
20
- desc "Run fixperms for the current project"
21
- task :fixperms do
22
- sudo "sh -c 'if [ -f /opt/kDeploy/tools/fixperms.py ] ; then cd /opt/kDeploy/tools/; python fixperms.py #{application}; fi'"
23
- end
28
+ task :fix do
29
+ sudo "chmod 777 -R `dirname $SSH_AUTH_SOCK`"
30
+ end
24
31
 
25
- desc "Make the SSH Authentication socket reachable for project user"
26
- task :fix_ssh_socket do
27
- sudo "chmod 777 -R `dirname $SSH_AUTH_SOCK`"
28
- end
32
+ task :unfix do
33
+ sudo "chmod 775 -R `dirname $SSH_AUTH_SOCK`"
34
+ end
29
35
 
30
- desc "Make the SSH Authentication socket reachable for project user"
31
- task :unfix_ssh_socket do
32
- sudo "chmod 775 -R `dirname $SSH_AUTH_SOCK`"
33
36
  end
34
37
 
35
- desc "Reload PHP5 fpm"
36
- task :fpmreload do
37
- sudo "/etc/init.d/php5-fpm reload"
38
+ namespace :fix do
39
+
40
+ desc "Run fixcron for the current project"
41
+ task :cron do
42
+ sudo "sh -c 'if [ -f /opt/kDeploy/tools/fixcron.py ] ; then cd /opt/kDeploy/tools/; python fixcron.py #{application}; fi'"
43
+ end
44
+
45
+ desc "Run fixperms for the current project"
46
+ task :perms do
47
+ sudo "sh -c 'if [ -f /opt/kDeploy/tools/fixperms.py ] ; then cd /opt/kDeploy/tools/; python fixperms.py #{application}; fi'"
48
+ end
49
+
38
50
  end
39
51
 
40
- desc "Restart PHP5 fpm"
41
- task :fpmrestart do
42
- sudo "/etc/init.d/php5-fpm restart"
52
+ namespace :fpm do
53
+
54
+ desc "Reload PHP5 fpm"
55
+ task :reload do
56
+ sudo "/etc/init.d/php5-fpm reload"
57
+ end
58
+
59
+ desc "Restart PHP5 fpm"
60
+ task :restart do
61
+ sudo "/etc/init.d/php5-fpm restart"
62
+ end
63
+
43
64
  end
44
65
 
45
- desc "Clear the APC cache"
46
- task :apcclear do
47
- serverproject = domain.split('.')[0]
48
- sudo "sh -c 'curl https://raw.github.com/gist/3987685/ > /home/projects/#{serverproject}/site/apcclear.php'"
49
- sudo "chmod 777 /home/projects/#{serverproject}/site/apcclear.php"
50
- sudo "curl http://#{domain}/apcclear.php"
66
+ namespace :apc do
67
+
68
+ desc "Clear the APC cache"
69
+ task :clear do
70
+ serverproject = domain.split('.')[0]
71
+ sudo "sh -c 'curl https://raw.github.com/gist/3987685/ > /home/projects/#{serverproject}/site/apcclear.php'"
72
+ sudo "chmod 777 /home/projects/#{serverproject}/site/apcclear.php"
73
+ sudo "curl http://#{domain}/apcclear.php"
74
+ end
75
+
51
76
  end
52
77
 
53
78
  end
@@ -55,65 +80,69 @@ end
55
80
  namespace :deploy do
56
81
 
57
82
  task :create_symlink, :except => { :no_release => true } do
58
- on_rollback do
59
- if previous_release
60
- try_sudo "ln -sf #{previous_release} #{current_path}; true"
61
- else
62
- logger.important "no previous release to rollback to, rollback of symlink skipped"
63
- end
83
+ on_rollback do
84
+ if previous_release
85
+ try_sudo "ln -sf #{previous_release} #{current_path}; true"
86
+ else
87
+ logger.important "no previous release to rollback to, rollback of symlink skipped"
64
88
  end
65
- try_sudo "ln -sfT #{latest_release} #{current_path}"
66
89
  end
90
+ try_sudo "ln -sfT #{latest_release} #{current_path}"
91
+ end
67
92
 
68
- end
93
+ desc "Deploy and run pending migrations"
94
+ task :migrations, :roles => :app, :except => { :no_release => true }, :only => { :primary => true } do
95
+ set :force_migrations, true
96
+ deploy.update
97
+ deploy.restart
98
+ end
69
99
 
70
- namespace :symfony do
100
+ namespace :schema do
101
+
102
+ desc "Deploy and update the schema"
103
+ task :update, :roles => :app, :except => { :no_release => true }, :only => { :primary => true } do
104
+ set :force_schema, true
105
+ deploy.update
106
+ deploy.restart
107
+ end
71
108
 
72
- desc "Copy vendors from previous release"
73
- task :copy_vendors, :except => { :no_release => true } do
74
- pretty_print "--> Copying vendors from previous release"
75
- try_sudo "mkdir #{release_path}/vendor"
76
- try_sudo "sh -c 'if [ -d #{previous_release}/vendor ] ; then cp -a #{previous_release}/vendor/* #{release_path}/vendor/; fi'"
77
- puts_ok
78
109
  end
79
110
 
80
- namespace :doctrine do
81
- namespace :schema do
111
+ end
82
112
 
83
- desc "Update the database schema."
84
- task :update do
85
- if force_schema
86
- try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:schema:update --env=#{symfony_env_prod} --force'", :once => true
87
- end
88
- end
113
+ # make it possible to run schema:update and migrations:migrate at the right place in the flow
114
+ after "symfony:bootstrap:build" do
115
+ if model_manager == "doctrine"
116
+ if force_schema
117
+ symfony.doctrine.schema.update
118
+ end
89
119
 
120
+ if force_migrations
121
+ symfony.doctrine.migrations.migrate
90
122
  end
91
123
  end
92
-
93
124
  end
94
125
 
95
- before "symfony:vendors:install", "symfony:copy_vendors" # Symfony2 2.0.x
96
- before "symfony:composer:install", "symfony:copy_vendors" # Symfony2 2.1
97
- before "symfony:composer:update", "symfony:copy_vendors" # Symfony2 2.1
98
-
99
126
  # Fix the SSH socket so that it's reachable for the project user, this is needed to pass your local ssh keys to github
100
- before "symfony:vendors:install", "kuma:fix_ssh_socket"
101
- before "symfony:vendors:reinstall", "kuma:fix_ssh_socket"
102
- before "symfony:vendors:upgrade", "kuma:fix_ssh_socket"
103
- before "symfony:composer:update", "kuma:fix_ssh_socket"
104
- before "symfony:composer:install", "kuma:fix_ssh_socket"
105
- after "symfony:vendors:install", "kuma:unfix_ssh_socket"
106
- after "symfony:vendors:reinstall", "kuma:unfix_ssh_socket"
107
- after "symfony:vendors:upgrade", "kuma:unfix_ssh_socket"
108
- after "symfony:composer:update", "kuma:unfix_ssh_socket"
109
- after "symfony:composer:install", "kuma:unfix_ssh_socket"
110
-
111
- # ask to update the schema
112
- after "symfony:bootstrap:build", "symfony:doctrine:schema:update"
127
+ before "symfony:vendors:install", "kuma:ssh_socket:fix"
128
+ before "symfony:vendors:reinstall", "kuma:ssh_socket:fix"
129
+ before "symfony:vendors:upgrade", "kuma:ssh_socket:fix"
130
+ before "symfony:composer:update", "kuma:ssh_socket:fix"
131
+ before "symfony:composer:install", "kuma:ssh_socket:fix"
132
+ after "symfony:vendors:install", "kuma:ssh_socket:unfix"
133
+ after "symfony:vendors:reinstall", "kuma:ssh_socket:unfix"
134
+ after "symfony:vendors:upgrade", "kuma:ssh_socket:unfix"
135
+ after "symfony:composer:update", "kuma:ssh_socket:unfix"
136
+ after "symfony:composer:install", "kuma:ssh_socket:unfix"
113
137
 
114
138
  # clear the cache before the warmup
115
139
  before "symfony:cache:warmup", "symfony:cache:clear"
116
140
 
141
+ # set the right permissions on the vendor folder ...
142
+ after "symfony:composer:copy_vendors" do
143
+ sudo "chown -R #{application}:#{application} #{latest_release}/vendor"
144
+ end
145
+
117
146
  # Before update_code:
118
147
  ## Make the cached_copy readable for the current user
119
148
  before "deploy:update_code" do
@@ -138,8 +167,8 @@ before "deploy:finalize_update" do
138
167
  end
139
168
 
140
169
  after "deploy:finalize_update" do
141
- kuma.fpmreload
142
- kuma.apcclear
170
+ kuma.fpm.reload
171
+ kuma.apc.clear
143
172
  end
144
173
 
145
174
  before :deploy do
@@ -147,10 +176,7 @@ before :deploy do
147
176
  %x(ssh-add)
148
177
  end
149
178
 
150
- # After deploy:
151
- ## Notify the people on campfire of this deploy
152
- ## Notify airbrake to add a new deploy to the deploy history
153
179
  after :deploy do
154
- kuma::fixcron
180
+ kuma.fix.cron
155
181
  deploy::cleanup ## cleanup old releases
156
182
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kstrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.29
4
+ version: 0.0.30
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,16 +9,16 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-06 00:00:00.000000000 Z
12
+ date: 2013-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: capistrano
15
+ name: capifony
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 2.14.1
21
+ version: 2.2.7
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 2.14.1
29
+ version: 2.2.7
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: capistrano-ext
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -43,38 +43,6 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: 1.2.1
46
- - !ruby/object:Gem::Dependency
47
- name: capistrano_colors
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: 0.5.5
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: 0.5.5
62
- - !ruby/object:Gem::Dependency
63
- name: capifony
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - '='
68
- - !ruby/object:Gem::Version
69
- version: 2.1.15
70
- type: :runtime
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - '='
76
- - !ruby/object:Gem::Version
77
- version: 2.1.15
78
46
  - !ruby/object:Gem::Dependency
79
47
  name: json
80
48
  requirement: !ruby/object:Gem::Requirement
@@ -123,7 +91,7 @@ dependencies:
123
91
  - - ! '>='
124
92
  - !ruby/object:Gem::Version
125
93
  version: 1.6.11
126
- description: Deploying applications with Capistrano, Jenkins and GIT.
94
+ description: Deploying symfony2 applications for the kDeploy server setup.
127
95
  email: support@kunstmaan.be
128
96
  executables:
129
97
  - kumafy
@@ -160,5 +128,5 @@ rubyforge_project:
160
128
  rubygems_version: 1.8.25
161
129
  signing_key:
162
130
  specification_version: 3
163
- summary: Deploying applications with Capistrano, Jenkins and GIT.
131
+ summary: Deploying symfony2 applications for the kDeploy server setup.
164
132
  test_files: []