<commit_before>require 'mina/bundler'
require 'mina/rails'
require 'mina/unicorn/utility'

set_default :services_path                  , '/etc/init.d'

set_default :unicorn_config_template        , File.expand_path("../../templates/unicorn.rb", __FILE__)
set_default :unicorn_script_template        , File.expand_path("../../templates/unicorn.sh", __FILE__)
set_default :unicorn_socket                 , -> { "#{deploy_to}/#{shared_path}/sockets/unicorn.sock" }
set_default :unicorn_pid                    , -> { "#{deploy_to}/#{shared_path}/pids/unicorn.pid" }
set_default :unicorn_config                 , -> { "#{deploy_to}/#{shared_path}/config/unicorn.rb" }
set_default :unicorn_logs_path              , -> { "#{deploy_to}/#{shared_path}/logs" }
set_default :unicorn_script                 , -> { "#{services_path}/#{app}-unicorn" }
set_default :unicorn_workers                , 4
set_default :unicorn_bin                    , "#{bundle_prefix} unicorn" # you may prefer this over the line below
set_default :unicorn_user                   , "#{user}"
set_default :unicorn_group                  , "#{group}"

namespace :unicorn do
  include Mina::Unicorn::Utility

  desc "Upload and update (link) all Unicorn config files"
  task :update => [:upload, :link]

  desc "Setup Unicorn folders"
  task :setup do
    queue! %{
      echo "-----> Create Unicorn sockets folder"
      #{echo_cmd %[mkdir -p "#{deploy_to}/#{shared_path}/logs"]}
      #{echo_cmd %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/logs"]}
      
      echo "-----> Create Unicorn pids folder"
      #{echo_cmd %[mkdir -p "#{deploy_to}/#{shared_path}/logs"]}
      #{echo_cmd %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/logs"]}

      echo "-----> Create Unicorn logs folder"
      #{echo_cmd %[mkdir -p "#{deploy_to}/#{shared_path}/logs"]}
      #{echo_cmd %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/logs"]}
    }
  end

  desc "Link unicorn init script"
  task :link => :environment do
    queue %{
      echo "-----> Linking unicorn init script..."
      #{echo_cmd %[sudo cp #{config_path}/unicorn.sh #{unicorn_script}]}
      #{echo_cmd %[sudo chown #{unicorn_user}:#{unicorn_group} #{unicorn_script}]}
      #{echo_cmd %[sudo chmod ugo+x #{unicorn_script}]}
      #{echo_cmd %[sudo update-rc.d #{app}-unicorn defaults]}
    }
    queue check_ownership unicorn_user, unicorn_group, "#{unicorn_script}"
  end

  desc "Parses all Unicorn config files and uploads them to server"
  task :upload => [:'upload:config', :'upload:script']

  namespace :upload do
    desc "Parses Unicorn config file and uploads it to server"
    task :config => :environment do
      queue %{echo "-----> Uploading Unicorn config..."}
      upload_template 'Unicorn config', "#{unicorn_config_template}", "#{config_path}/unicorn.rb"
    end

    desc "Parses Unicorn control script file and uploads it to server"
    task :script => :environment do
      queue %{echo "-----> Uploading Unicorn init script..."}
      upload_template 'Unicorn init script', "#{unicorn_script_template}", "#{config_path}/unicorn.sh"<commit_msg>remove daemon before update template add setup task<commit_after>require 'mina/bundler'
require 'mina/rails'
require 'mina/unicorn/utility'

set_default :services_path                  , '/etc/init.d'

set_default :unicorn_config_template        , File.expand_path("../../templates/unicorn.rb", __FILE__)
set_default :unicorn_script_template        , File.expand_path("../../templates/unicorn.sh", __FILE__)
set_default :unicorn_socket                 , -> { "#{deploy_to}/#{shared_path}/sockets/unicorn.sock" }
set_default :unicorn_pid                    , -> { "#{deploy_to}/#{shared_path}/pids/unicorn.pid" }
set_default :unicorn_config                 , -> { "#{deploy_to}/#{shared_path}/config/unicorn.rb" }
set_default :unicorn_logs_path              , -> { "#{deploy_to}/#{shared_path}/logs" }
set_default :unicorn_script                 , -> { "#{services_path}/#{app}-unicorn" }
set_default :unicorn_workers                , 4
set_default :unicorn_bin                    , "#{bundle_prefix} unicorn" # you may prefer this over the line below
set_default :unicorn_user                   , "#{user}"
set_default :unicorn_group                  , "#{group}"

namespace :unicorn do
  include Mina::Unicorn::Utility

  desc "Upload and update (link) all Unicorn config files"
  task :update => [:'daemon:remove' :upload, :link]

  desc "Setup Unicorn folders"
  task :setup do
    queue! %{
      echo "-----> Create Unicorn sockets folder"
      #{echo_cmd %[mkdir -p "#{deploy_to}/#{shared_path}/logs"]}
      #{echo_cmd %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/logs"]}
      
      echo "-----> Create Unicorn pids folder"
      #{echo_cmd %[mkdir -p "#{deploy_to}/#{shared_path}/logs"]}
      #{echo_cmd %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/logs"]}

      echo "-----> Create Unicorn logs folder"
      #{echo_cmd %[mkdir -p "#{deploy_to}/#{shared_path}/logs"]}
      #{echo_cmd %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/logs"]}
    }

    invoke :update
  end

  desc "Link unicorn init script"
  task :link => :environment do
    queue %{
      echo "-----> Linking unicorn init script..."
      #{echo_cmd %[sudo cp #{config_path}/unicorn.sh #{unicorn_script}]}
      #{echo_cmd %[sudo chown #{unicorn_user}:#{unicorn_group} #{unicorn_script}]}
      #{echo_cmd %[sudo chmod ugo+x #{unicorn_script}]}
      #{echo_cmd %[sudo update-rc.d #{app}-unicorn defaults]}
    }
    queue check_ownership unicorn_user, unicorn_group, "#{unicorn_script}"
  end

  desc "Parses all Unicorn config files and uploads them to server"
  task :upload => [:'upload:config', :'upload:script']

  namespace :upload do
    desc "Parses Unicorn config file and uploads it to server"
    task :config => :environment do
      queue %{echo "-----> Uploading Unicorn config..."}
      upload_template 'Unicorn config', "#{unicorn_config_template}", "#{config_path}/unicorn.rb"
    end

    desc "Parses Unicorn control script file and uploads it to server"
    task :script => :environment do
      queue %{echo "-----> Uploading Unicorn init script..."}
      upload_template 'Unicorn init script', "#{unicorn_script_template}", "#{config_path}/unicorn.sh"
{'fraction_non_alphanumeric': 0.15609522287905417, 'fraction_numerical': 0.00031953986259785906, 'mean_word_length': 3.129287598944591, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, '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': '5871326', 'n_tokens_mistral': 2083, 'n_tokens_neox': 2015, 'n_words': 469}