<commit_before># config valid only for Capistrano 3.1
#lock '3.2.1'

# application and repo settings
set :application, 'scholarsphere'
set :repo_url, "https://github.com/psu-stewardship/#{fetch(:application)}.git"

# default branch is :master
#ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
set :branch, ENV["REVISION"] || ENV["BRANCH_NAME"] || "develop"

# default user and deployment location
set :user, "deploy"
set :deploy_to, "/opt/heracles/deploy/#{fetch(:application)}"
set :use_sudo, false

# ssh key settings
set :ssh_options, {
    keys: [File.join(ENV["HOME"], ".ssh", "id_deploy_rsa")],
    forward_agent: true,
    #auth_methods: %w(password)
    #keys: %w(/home/rlisowski/.ssh/id_rsa),  
}

# rbenv settings
set :rbenv_type, :user # or :system, depends on your rbenv setup
set :rbenv_ruby, File.read(File.join(File.dirname(__FILE__), '..', '.ruby-version')).chomp # read from file above
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec" # rbenv settings
set :rbenv_map_bins, %w{rake gem bundle ruby rails} # map the following bins
set :rbenv_roles, :all # default value

#set passenger to just the web servers
set :passenger_roles, :web

# rails settings, NOTE: Task is wired into event stack
set :rails_env, 'production'

# whenever settings, NOTE: Task is wired into event stack
set :whenever_identifier, -> {"#{fetch(:application)}_#{fetch(:stage)}"}
set :whenever_roles, [:app, :job]

# git for source control
set :scm, :git
#set :git_strategy, Capistrano::Git::SubmoduleStrategy

# Default value for :format is :pretty
set :format, :pretty

# Default value for :log_level is :debug
set :log_level, :debug

# Default value for :pty is false
set :pty, true

# Default value for :linked_files is []
#set :linked_files, %w{config/database.yml}

# Default value for linked_dirs is []
# set :linked_dirs, %w{log}
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for keep_releases is 5, setting to 7
set :keep_releases, 7


# Apache namespace to control apache
namespace :apache do
 [:stop, :start, :restart, :reload].each do |action|
 desc "#{action.to_s.capitalize} Apache"
  task action do
   on roles(:web) do
    execute "sudo service httpd #{action.to_s}"
   end
  end
 end
end

namespace :deploy do
  
  # Link the appropriate configuration files based on application, stage, and release path
  desc "Link shared files"
  task :symlink_shared do
  on roles(:app) do
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/database.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/devise.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/fedora.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/hydra-ldap.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/newrelic.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/redis.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/solr.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/analytics.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/ga-privatekey.p12 #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/browse_everything_providers.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/secret_token.rb #{fetch(:release_path)}/config/initializers/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/sufia-secret.rb #{fetch(:release_path)}/config/initializers/"
    execute "ln -sf /dlt/#{fetch(:application)}/upload_#{fetch(:stage)}/uploads #{fetch(:release_path)}/public/"
    execute "ln -sf /dlt/#{fetch(:application)}/shared_#{fetch(:stage)}/public/sitemap.xml #{fetch(:release_path)}/public/sitemap.xml"
    end
  end
  after 'deploy:symlink:shared', :symlink_shared 

  # Resolarize objects
  desc "Re-solrize objects"
  task :resolrize do
   on roles(:job) do
    within release_path do
     with rails_env: fetch(:rails_env) do
      execute :rake, "#{fetch(:application)}:resolrize"
     end
   end
  end
 end
 after :migrate, :resolrize

 # Restart resque-pool.
 desc "Restart resque-pool"
 task :resquepoolrestart do
  on roles(:job) do
    execute :sudo,  "/sbin/service resque_pool restart"
  end
 end
 before :restart, :resquepoolrestart<commit_msg>Adding symbolic link for system directory so avatars are shared across deployments and systems.  fixes #8956<commit_after># config valid only for Capistrano 3.1
#lock '3.2.1'

# application and repo settings
set :application, 'scholarsphere'
set :repo_url, "https://github.com/psu-stewardship/#{fetch(:application)}.git"

# default branch is :master
#ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
set :branch, ENV["REVISION"] || ENV["BRANCH_NAME"] || "develop"

# default user and deployment location
set :user, "deploy"
set :deploy_to, "/opt/heracles/deploy/#{fetch(:application)}"
set :use_sudo, false

# ssh key settings
set :ssh_options, {
    keys: [File.join(ENV["HOME"], ".ssh", "id_deploy_rsa")],
    forward_agent: true,
    #auth_methods: %w(password)
    #keys: %w(/home/rlisowski/.ssh/id_rsa),  
}

# rbenv settings
set :rbenv_type, :user # or :system, depends on your rbenv setup
set :rbenv_ruby, File.read(File.join(File.dirname(__FILE__), '..', '.ruby-version')).chomp # read from file above
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec" # rbenv settings
set :rbenv_map_bins, %w{rake gem bundle ruby rails} # map the following bins
set :rbenv_roles, :all # default value

#set passenger to just the web servers
set :passenger_roles, :web

# rails settings, NOTE: Task is wired into event stack
set :rails_env, 'production'

# whenever settings, NOTE: Task is wired into event stack
set :whenever_identifier, -> {"#{fetch(:application)}_#{fetch(:stage)}"}
set :whenever_roles, [:app, :job]

# git for source control
set :scm, :git
#set :git_strategy, Capistrano::Git::SubmoduleStrategy

# Default value for :format is :pretty
set :format, :pretty

# Default value for :log_level is :debug
set :log_level, :debug

# Default value for :pty is false
set :pty, true

# Default value for :linked_files is []
#set :linked_files, %w{config/database.yml}

# Default value for linked_dirs is []
# set :linked_dirs, %w{log}
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for keep_releases is 5, setting to 7
set :keep_releases, 7


# Apache namespace to control apache
namespace :apache do
 [:stop, :start, :restart, :reload].each do |action|
 desc "#{action.to_s.capitalize} Apache"
  task action do
   on roles(:web) do
    execute "sudo service httpd #{action.to_s}"
   end
  end
 end
end

namespace :deploy do
  
  # Link the appropriate configuration files based on application, stage, and release path
  desc "Link shared files"
  task :symlink_shared do
  on roles(:app) do
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/database.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/devise.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/fedora.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/hydra-ldap.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/newrelic.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/redis.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/solr.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/analytics.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/ga-privatekey.p12 #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/browse_everything_providers.yml #{fetch(:release_path)}/config/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/secret_token.rb #{fetch(:release_path)}/config/initializers/"
    execute "ln -sf /dlt/#{fetch(:application)}/config_#{fetch(:stage)}/#{fetch(:application)}/sufia-secret.rb #{fetch(:release_path)}/config/initializers/"
    execute "ln -sf /dlt/#{fetch(:application)}/upload_#{fetch(:stage)}/uploads #{fetch(:release_path)}/public/"
    execute "ln -sf /dlt/#{fetch(:application)}/shared_#{fetch(:stage)}/public/sitemap.xml #{fetch(:release_path)}/public/sitemap.xml"
    execute "ln -sf /dlt/#{fetch(:application)}/shared_#{fetch(:stage)}/public/system #{fetch(:release_path)}/public/"
    end
  end
  after 'deploy:symlink:shared', :symlink_shared 

  # Resolarize objects
  desc "Re-solrize objects"
  task :resolrize do
   on roles(:job) do
    within release_path do
     with rails_env: fetch(:rails_env) do
      execute :rake, "#{fetch(:application)}:resolrize"
     end
   end
  end
 end
 after :migrate, :resolrize

 # Restart resque-pool.
 desc "Restart resque-pool"
 task :resquepoolrestart do
  on roles(:job) do
    execute :sudo,  "/sbin/service resque_pool restart"
  end
 end
 before :restart, :resquepoolrestart
{'fraction_non_alphanumeric': 0.1706116265858739, 'fraction_numerical': 0.0022722969134633592, 'mean_word_length': 5.313807531380753, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '181117', 'n_tokens_mistral': 3656, 'n_tokens_neox': 3566, 'n_words': 841}