Sha256: 4106451d23287e02597e899fc7106a784181b5103800d3ba3852db94926219f3

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

namespace :forkcms do
  namespace :maintenance do
    desc 'Enable maintenance mode'
    task :enable do
      on roles(:web) do
        create_maintenance_folder
        execute :rm, '-rf', "#{fetch :document_root} && ln -sf #{shared_path}/maintenance #{fetch :document_root}"
      end
    end

    desc 'Disable maintenance mode'
    task :disable do
      on roles(:web) do
        execute :rm, '-rf', "#{fetch :document_root} && ln -sf #{current_path} #{fetch :document_root}"
      end
    end

    private
    # Creates the maintenance folder based on the local maintenance folder to display when migrating
    def create_maintenance_folder
      # Stop if the maintenance folder exists
      return if capture("if [ -d #{shared_path}/maintenance ]; then echo 'yes'; fi").chomp == 'yes'

      lib_path = File.dirname(__FILE__)
      local_maintenance_path = "#{lib_path}/../../maintenance"

      # Create a maintenance folder containing the index page from our gem
      execute :mkdir, "-p #{shared_path}/maintenance"

      # copy the contents of the index.html file to our shared folder
      upload! File.open(local_maintenance_path + '/index.html'), "#{shared_path}/maintenance/index.html"

      # copy the contents of the .htaccess file to our shared folder
      upload! File.open(local_maintenance_path + '/.htaccess'), "#{shared_path}/maintenance/.htaccess"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capistrano-forkcms-3.1.2 lib/capistrano/tasks/maintenance.rake
capistrano-forkcms-3.1.0 lib/capistrano/tasks/maintenance.rake
capistrano-forkcms-3.0.0 lib/capistrano/tasks/maintenance.rake