<commit_before>#############################################################
#	Multi-staging
#############################################################

set :stages, %w(production staging)
set :default_stage, 'staging'
require 'capistrano/ext/multistage'

#############################################################
#	Application
#############################################################

set :application, 'feedbunch'

#############################################################
#	RVM
#############################################################

set :rvm_ruby_string, 'ruby-1.9.3-p429@feedbunch'
set :rvm_type, :system
require 'rvm/capistrano'

#############################################################
#	Settings
#############################################################

# runs 'bundle install' during deployment
require 'bundler/capistrano'

# precompiles assets in production
load 'deploy/assets'

default_environment['TERM'] = 'xterm'

#############################################################
#	Servers
#############################################################

set :user, 'feedbunch'
# We use a non-privileged user for security reasons
set :use_sudo, false
set :deploy_to, '/var/rails/feedbunch'

#############################################################
#	Git
#############################################################

set :scm, :git
set :repository,  'git://github.com/amatriain/feedbunch.git'
set :branch, 'master'
set :deploy_via, :remote_cache

#############################################################
#	Passenger
#############################################################

namespace :feedbunch_passenger do
  task :restart, roles: :app do
    # Tell passenger to restart the app
    run "touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

#############################################################
#	God (manages Redis, Resque)
#############################################################

namespace :feedbunch_god do
  task :start, roles: :background do
    run "cd #{current_path};
        RAILS_ENV=#{rails_env} RESQUE_ENV=background bundle exec god -c #{File.join(current_path,'config','background_jobs.god')}"
  end

  task :stop, roles: :background do
    # We run a "true" shell command after issuing a "god terminate" command because otherwise if
    # God were not running before this, we would get a return value of false which
    # Capistrano would intepret as an error and the deployment would be rolled back
    run "cd #{current_path};
        bundle exec god terminate;
        true"
  end

  task :restart, roles: :background do
    feedbunch_god.stop
    feedbunch_god.start
  end
end

#############################################################
#	Copy per-environment config files to deployment
#############################################################

namespace :feedbunch_secret_data do
  task :copy, roles: [:app, :background], except: {no_release: true} do

    run 'ln -sf /home/feedbunch/config/database.yml ' \
        "#{release_path}/config/database.yml"

    copy_app
    copy_background
  end

  task :copy_app, roles: :app do
    run 'ln -sf /home/feedbunch/config/secret_token.rb ' \
        "#{release_path}/config/initializers/secret_token.rb"

    run "ln -sf /home/feedbunch/config/#{rails_env}.rb " \
        "#{release_path}/config/environments/#{rails_env}.rb"
  end

  task :copy_background, roles: :background do
    run 'ln -sf /home/feedbunch/config/notifications.god ' \
        "#{release_path}/config/notifications.god"

    # Redis working directory is in the capistrano shared folder, so that the
    # append-only file and the dump file are not lost on each deployment. Create it if necessary.
    run "mkdir -p #{shared_path}/redis"

    run 'ln -sf /home/feedbunch/config/redis.conf ' \
        "#{release_path}/redis/redis.conf"<commit_msg>Capistrano links the file with the (secret) AWS key to the config/initializers folder of the deployment.<commit_after>#############################################################
#	Multi-staging
#############################################################

set :stages, %w(production staging)
set :default_stage, 'staging'
require 'capistrano/ext/multistage'

#############################################################
#	Application
#############################################################

set :application, 'feedbunch'

#############################################################
#	RVM
#############################################################

set :rvm_ruby_string, 'ruby-1.9.3-p429@feedbunch'
set :rvm_type, :system
require 'rvm/capistrano'

#############################################################
#	Settings
#############################################################

# runs 'bundle install' during deployment
require 'bundler/capistrano'

# precompiles assets in production
load 'deploy/assets'

default_environment['TERM'] = 'xterm'

#############################################################
#	Servers
#############################################################

set :user, 'feedbunch'
# We use a non-privileged user for security reasons
set :use_sudo, false
set :deploy_to, '/var/rails/feedbunch'

#############################################################
#	Git
#############################################################

set :scm, :git
set :repository,  'git://github.com/amatriain/feedbunch.git'
set :branch, 'master'
set :deploy_via, :remote_cache

#############################################################
#	Passenger
#############################################################

namespace :feedbunch_passenger do
  task :restart, roles: :app do
    # Tell passenger to restart the app
    run "touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

#############################################################
#	God (manages Redis, Resque)
#############################################################

namespace :feedbunch_god do
  task :start, roles: :background do
    run "cd #{current_path};
        RAILS_ENV=#{rails_env} RESQUE_ENV=background bundle exec god -c #{File.join(current_path,'config','background_jobs.god')}"
  end

  task :stop, roles: :background do
    # We run a "true" shell command after issuing a "god terminate" command because otherwise if
    # God were not running before this, we would get a return value of false which
    # Capistrano would intepret as an error and the deployment would be rolled back
    run "cd #{current_path};
        bundle exec god terminate;
        true"
  end

  task :restart, roles: :background do
    feedbunch_god.stop
    feedbunch_god.start
  end
end

#############################################################
#	Copy per-environment config files to deployment
#############################################################

namespace :feedbunch_secret_data do
  task :copy, roles: [:app, :background], except: {no_release: true} do

    run 'ln -sf /home/feedbunch/config/database.yml ' \
        "#{release_path}/config/database.yml"

    run 'ln -sf /home/feedbunch/config/aws_key.rb ' \
        "#{release_path}/config/initializers/aws_key.rb"

    copy_app
    copy_background
  end

  task :copy_app, roles: :app do
    run 'ln -sf /home/feedbunch/config/secret_token.rb ' \
        "#{release_path}/config/initializers/secret_token.rb"

    run "ln -sf /home/feedbunch/config/#{rails_env}.rb " \
        "#{release_path}/config/environments/#{rails_env}.rb"
  end

  task :copy_background, roles: :background do
    run 'ln -sf /home/feedbunch/config/notifications.god ' \
        "#{release_path}/config/notifications.god"

    # Redis working directory is in the capistrano shared folder, so that the
    # append-only file and the dump file are not lost on each deployment. Create it if necessary.
    run "mkdir -p #{shared_path}/redis"

    run 'ln -sf /home/feedbunch/config/redis.conf ' \
        "#{release_path}/redis/redis.conf"
{'fraction_non_alphanumeric': 0.35575109993714643, 'fraction_numerical': 0.001508485229415462, 'mean_word_length': 5.431689571544058, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2527134', 'n_tokens_mistral': 2208, 'n_tokens_neox': 2089, 'n_words': 557}