<commit_before>require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/deploy_status'
require 'varvet'

def create_runit_task(ps)
  namespace :runit do
    namespace ps do
      [:restart,:stop,:start,:reload,:status].each do |cmd|
        desc "#{cmd} #{ps}"
        task cmd do
          on roles(:all) do |host|
            execute "sv #{cmd.to_s} /home/deploy/service/#{fetch(:application)}-#{ps.to_s}-1"
          end
        end
      end
    end
  end
end

config = Varvet::VarvetConfig.config
set :application, config.fetch('application')
set :repo_url,  config.fetch('repo_url')

set :ssh_options, {
  user: 'deploy'
}

set :branch, "master"
set :deploy_via, :remote_cache
set :deploy_to, "/var/www/#{fetch(:application)}"

set :assets_roles, [:app] #defaults to :web
set :migration_role, :migrator

create_runit_task(:web)

namespace :deploy do
  task :runit do
    on roles(:all) do |host|
      execute "cd #{release_path} && bundle exec varvet postdeploy #{fetch(:rails_env}"
      invoke 'runit:web:restart'
      3.times do |i|
        begin
          puts 'waiting on restart to finish..'
          sleep i
          invoke 'deploy:status'
          break
        rescue Exception  => e
          puts "try #{i+1}/3 failed."
          Rake::Task["deploy:status"].reenable
        end
      end
    end
  end
end



after 'deploy:finished', 'deploy:set_current_version'
after 'deploy:finished', 'deploy:runit'

<commit_msg>Fix rails_env<commit_after>require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/deploy_status'
require 'varvet'

def create_runit_task(ps)
  namespace :runit do
    namespace ps do
      [:restart,:stop,:start,:reload,:status].each do |cmd|
        desc "#{cmd} #{ps}"
        task cmd do
          on roles(:all) do |host|
            execute "sv #{cmd.to_s} /home/deploy/service/#{fetch(:application)}-#{ps.to_s}-1"
          end
        end
      end
    end
  end
end

config = Varvet::VarvetConfig.config
set :application, config.fetch('application')
set :repo_url,  config.fetch('repo_url')

set :ssh_options, {
  user: 'deploy'
}

set :branch, "master"
set :deploy_via, :remote_cache
set :deploy_to, "/var/www/#{fetch(:application)}"

set :assets_roles, [:app] #defaults to :web
set :migration_role, :migrator

create_runit_task(:web)

namespace :deploy do
  task :runit do
    on roles(:all) do |host|
      execute "cd #{release_path} && bundle exec varvet postdeploy #{fetch(:rails_env)}"
      invoke 'runit:web:restart'
      3.times do |i|
        begin
          puts 'waiting on restart to finish..'
          sleep i
          invoke 'deploy:status'
          break
        rescue Exception  => e
          puts "try #{i+1}/3 failed."
          Rake::Task["deploy:status"].reenable
        end
      end
    end
  end
end



after 'deploy:finished', 'deploy:set_current_version'
after 'deploy:finished', 'deploy:runit'


{'fraction_non_alphanumeric': 0.1286493423163298, 'fraction_numerical': 0.0025665704202759063, 'mean_word_length': 3.1026315789473684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2114366', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1039, 'n_words': 261}