<commit_before>default_run_options[:pty] = true

set :application, "announce"
set :repository,  "<EMAIL>:recursivecreative/announce.git"
set :backup_repository, "<EMAIL>:recursivecreative/backups.git"

set :deploy_to, "/home/deploy/#{application}"
set :user, "deploy"
set :use_sudo, false
set :port, "42832"

set :scm, :git

role :app, "192.168.127.12"
role :web, "192.168.127.12"
role :db,  "192.168.127.12", :primary => true

before 'deploy:update', 'db:dump'

namespace :db do
  task :backup_name, :roles => :db, :only => { :primary => true } do
    now = Time.now
    run "mkdir -p #{shared_path}/db_backups"
    backup_time = [now.year,now.month,now.day,now.hour,now.min,now.sec].join('-')
    set :backup_file, "#{shared_path}/db_backups/announce_production-snapshot-#{backup_time}.sql"
  end

  desc "Backup your database to shared_path+/db_backups"
  task :dump, :roles => :db, :only => {:primary => true} do
    backup_name
    database_info = YAML.load_file('config/database.yml')['production']
    run "mysqldump --add-drop-table -u #{database_info['username']} -p#{database_info['password']} announce_production | bzip2 -c > #{backup_file}.bz2"
  end
  
  desc "Sync your production database to your local workstation"
  task :clone_to_local, :roles => :db, :only => {:primary => true} do
    backup_name
    dump
    get "#{backup_file}.bz2", "/tmp/#{application}.sql.gz"
    development_info = YAML.load_file("config/database.yml")['development']
    local_db_password = development_info['password'] ? " -p#{development_info['password']}" : ''
    run_str = "bzcat /tmp/#{application}.sql.gz | mysql -u #{development_info['username']}#{local_db_password}  #{development_info['database']}"
    %x!#{run_str}!
  end
end

namespace :deploy do
  desc "Restarting mod_rails with restart.txt"
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{current_path}/tmp/restart.txt"
  end
  
  [:start, :stop].each do |t|
    desc "#{t} task is a no-op with mod_rails"
    task t, :roles => :app do ; end
  end
end

namespace :slicehost do
  desc "Configure crontab for deploy user"
  task :config_crontab do
    # carriage return at end is required, or it will not run!
    crontab =<<-EOF
MAILTO = <EMAIL>
@daily echo "cd #{current_path} && rake db2s3:backup:full"

    EOF
    put crontab, "src/crontab"
    run "crontab -u #{user} src/crontab"
  end
  
  desc "Configure VHost"
  task :config_vhost do
    vhost_config =<<-EOF
<VirtualHost *:80>
  ServerName announceitapp.com
  DocumentRoot #{current_path}/public
</VirtualHost>
    EOF
    put vhost_config, "src/vhost_config"
    sudo "mv src/vhost_config /etc/apache2/sites-available/#{application}"
    sudo "a2ensite #{application}"
  end
  
  desc "Reload Apache"
  task :apache_reload do
    sudo "/etc/init.d/apache2 reload"
  end
end<commit_msg>Crontab for backup<commit_after>default_run_options[:pty] = true

set :application, "announce"
set :repository,  "<EMAIL>:recursivecreative/announce.git"
set :backup_repository, "<EMAIL>:recursivecreative/backups.git"

set :deploy_to, "/home/deploy/#{application}"
set :user, "deploy"
set :use_sudo, false
set :port, "42832"

set :scm, :git

role :app, "192.168.127.12"
role :web, "192.168.127.12"
role :db,  "192.168.127.12", :primary => true

before 'deploy:update', 'db:dump'

namespace :db do
  task :backup_name, :roles => :db, :only => { :primary => true } do
    now = Time.now
    run "mkdir -p #{shared_path}/db_backups"
    backup_time = [now.year,now.month,now.day,now.hour,now.min,now.sec].join('-')
    set :backup_file, "#{shared_path}/db_backups/announce_production-snapshot-#{backup_time}.sql"
  end

  desc "Backup your database to shared_path+/db_backups"
  task :dump, :roles => :db, :only => {:primary => true} do
    backup_name
    database_info = YAML.load_file('config/database.yml')['production']
    run "mysqldump --add-drop-table -u #{database_info['username']} -p#{database_info['password']} announce_production | bzip2 -c > #{backup_file}.bz2"
  end
  
  desc "Sync your production database to your local workstation"
  task :clone_to_local, :roles => :db, :only => {:primary => true} do
    backup_name
    dump
    get "#{backup_file}.bz2", "/tmp/#{application}.sql.gz"
    development_info = YAML.load_file("config/database.yml")['development']
    local_db_password = development_info['password'] ? " -p#{development_info['password']}" : ''
    run_str = "bzcat /tmp/#{application}.sql.gz | mysql -u #{development_info['username']}#{local_db_password}  #{development_info['database']}"
    %x!#{run_str}!
  end
end

namespace :deploy do
  desc "Restarting mod_rails with restart.txt"
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{current_path}/tmp/restart.txt"
  end
  
  [:start, :stop].each do |t|
    desc "#{t} task is a no-op with mod_rails"
    task t, :roles => :app do ; end
  end
end

namespace :slicehost do
  desc "Configure crontab for deploy user"
  task :config_crontab do
    # carriage return at end is required, or it will not run!
    crontab =<<-EOF
MAILTO = <EMAIL>
@daily cd #{current_path} && RAILS_ENV=production rake db2s3:backup:full"

    EOF
    put crontab, "src/crontab"
    run "crontab -u #{user} src/crontab"
  end
  
  desc "Configure VHost"
  task :config_vhost do
    vhost_config =<<-EOF
<VirtualHost *:80>
  ServerName announceitapp.com
  DocumentRoot #{current_path}/public
</VirtualHost>
    EOF
    put vhost_config, "src/vhost_config"
    sudo "mv src/vhost_config /etc/apache2/sites-available/#{application}"
    sudo "a2ensite #{application}"
  end
  
  desc "Reload Apache"
  task :apache_reload do
    sudo "/etc/init.d/apache2 reload"
  end
end
{'fraction_non_alphanumeric': 0.15161064425770307, 'fraction_numerical': 0.01680672268907563, 'mean_word_length': 4.160794941282746, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, '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': '6369086', 'n_tokens_mistral': 2152, 'n_tokens_neox': 2051, 'n_words': 499}