Module: KStrano::Wordpress

Defined in:
lib/kstrano_wordpress.rb

Class Method Summary collapse

Class Method Details

.load_into(configuration) ⇒ Object



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
# File 'lib/kstrano_wordpress.rb', line 6

def self.load_into(configuration)
  configuration.load do

    load_paths.push File.expand_path('../', __FILE__)
    load 'kstrano'

    namespace :deploy do
      desc "Updates latest release source path"
      task :finalize_update, :roles => :app, :except => { :no_release => true } do
        run "#{try_sudo} chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
        kuma::share_childs
      end
    end

    namespace :kuma do
      namespace :fpm do
          desc "Reload PHP5 fpm"
          task :reload do
            sudo "/etc/init.d/php5-fpm reload"
          end

          desc "Restart PHP5 fpm"
          task :restart do
            sudo "/etc/init.d/php5-fpm restart"
          end

          desc "Gracefully restart PHP5 fpm"
          task :graceful_restart do
            sudo "pkill -QUIT -f \"^php-fpm: pool #{application} \" "
          end
        end

        namespace :apc do
          desc "Prepare for APC cache clear"
          task :prepare_clear do
            server_project_name = "#{server_name}"
            if server_project_name.nil? || server_project_name.empty?
              server_project_name = domain.split('.')[0]
            end
            sudo "sh -c 'if [ ! -f /home/projects/#{server_project_name}/site/apcclear.php ]; then curl https://raw.github.com/Kunstmaan/kStrano/master/resources/symfony2/apcclear.php > /home/projects/#{server_project_name}/site/apcclear.php; fi'"
            sudo "chmod 777 /home/projects/#{server_project_name}/site/apcclear.php"
          end

          desc "Clear the APC cache"
          task :clear do
            hostname = "#{domain}"
            server_project_name = "#{server_name}"
            if !server_project_name.nil? && !server_project_name.empty?
              hostname = "#{server_project_name}.#{hostname}"
            end
            sudo "curl http://#{hostname}/apcclear.php"
          end
        end
      end

    before "deploy:finalize_update", "kuma:apc:prepare_clear"
    after "deploy:finalize_update", "kuma:apc:clear", "kuma:fpm:graceful_restart"
    after "deploy:create_symlink", "kuma:apc:clear", "kuma:fpm:graceful_restart"
    end
end