<commit_before># @author <NAME> <<EMAIL>>
require File.expand_path(File.dirname(__FILE__) + '/../utilities')

# This Nginx is targeted for the :web role meant to be acting as a front end
# to a unicorn based application

# Additions
# https://github.com/newobj/nginx-x-rid-header
# https://github.com/yaoweibin/nginx_syslog_patch

# Possible Future Additions
# https://support.newrelic.com/kb/features/tracking-front-end-time

Capistrano::Configuration.instance(true).load do

  namespace :nginx do
    roles[:nginx]
    roles[:nginx_client]

    set :nginx_init_d, "nginx"
    set :nginx_root, "/opt/nginx"
    set :nginx_conf_path, File.join(File.dirname(__FILE__),'nginx.conf')
    set :nginx_init_d_path, File.join(File.dirname(__FILE__),'nginx.init')
    set :nginx_stub_conf_path, File.join(File.dirname(__FILE__),'stub_status.conf')
    set :nginx_god_path, File.join(File.dirname(__FILE__),'nginx.god')
    set :nginx_logrotate_path, File.join(File.dirname(__FILE__),'nginx.logrotate')
    # must be above 1.1.7 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-1180
    set :nginx_src, "http://nginx.org/download/nginx-1.2.0.tar.gz"
    set(:nginx_ver) { nginx_src.match(/\/([^\/]*)\.tar\.gz$/)[1] }
    set(:nginx_source_dir) {"#{nginx_root}/src/#{nginx_ver}"}
    set(:nginx_patch_dir) {"#{nginx_root}/src"}
    set(:nginx_log_dir) {"#{nginx_root}/logs"}
    set(:nginx_pid_file) {"#{nginx_log_dir}/nginx.pid"}
    set :nginx_watcher, nil
    set :nginx_user, "nobody"
    set :nginx_suppress_runner, false
    set :nginx_port, '80'
    set :nginx_ssl_port, '443'
    set :nginx_bind_eth, nil
    set(:nginx_bind) {"###ETH###" if nginx_bind_eth}
    set(:nginx_listen) {"#{nginx_bind}:#{nginx_port}"}
    set(:nginx_ssl_listen) {"#{nginx_bind}:#{nginx_ssl_port} ssl"}
    set :nginx_server_name, 'localhost'
    set(:nginx_server_names) {nginx_server_name}
    set :nginx_app_conf_path, File.join(File.dirname(__FILE__),'app.conf')
    set :nginx_worker_processes, "1" # should be cpu's - 1
    set(:nginx_app_conf_filename) { application }
    set(:nginx_configure_flags) {[
      "--with-debug",
      "--with-http_gzip_static_module",
      "--with-http_stub_status_module",
      "--with-http_ssl_module",
      "--add-module=#{nginx_patch_dir}/nginx_syslog_patch",
      "--add-module=#{nginx_patch_dir}/nginx-x-rid-header",
      "--with-ld-opt=-lossp-uuid",
      "--with-cc-opt=-I/usr/include/ossp"
    ]}
    set :nginx_cert_name, nil
    set :nginx_cert_path, nil
    set(:nginx_cert_location) { "#{nginx_root}/conf/keys"}
    set :uninstall_apt_nginx, false #false may cause problems with the init.d and leave orhpans, true will destroy the remnants of whatever used to be there.
    set :nginx_redirect_www_to_base_domain, true
    set :nginx_upload_certs, true
    set :nginx_max_fails, "10"
    set :nginx_fail_timeout, "15"
    set :nginx_redirects, nil

    def ipaddress(eth)
      %Q{`ifconfig #{eth} | awk '/inet addr/ {split ($2,A,":"); print A[2]}'`}
    end

    task :upload_certs, :roles => [:web,:nginx,:nginx_client] do
      if nginx_cert_name and nginx_upload_certs
        utilities.sudo_upload_template File.join(nginx_cert_path,"#{nginx_cert_name}.key"), "#{nginx_cert_location}/#{nginx_cert_name}.key"
        utilities.sudo_upload_template File.join(nginx_cert_path,"#{nginx_cert_name}.crt"), "#{nginx_cert_location}/#{nginx_cert_name}.crt"
      end
    end

    desc "select watcher"
    task :watcher do
      nginx.send("watch_with_#{nginx_watcher}".to_sym) unless nginx_watcher.nil?
    end

    desc "Use GOD as nginx's runner"
    task :watch_with_god do
      #rejigger the maintenance tasks to use god when god is in play
      %w(start stop restart).each do |t|
        task t.to_sym, :roles => :web do
          god.cmd "#{t} nginx" unless nginx_suppress_runner
        end
      end
      after "god:setup", "nginx:setup_god"
    end
<commit_msg>ensure that nginx_client makes the cert location directory before trying to upload certs.<commit_after># @author <NAME> <<EMAIL>>
require File.expand_path(File.dirname(__FILE__) + '/../utilities')

# This Nginx is targeted for the :web role meant to be acting as a front end
# to a unicorn based application

# Additions
# https://github.com/newobj/nginx-x-rid-header
# https://github.com/yaoweibin/nginx_syslog_patch

# Possible Future Additions
# https://support.newrelic.com/kb/features/tracking-front-end-time

Capistrano::Configuration.instance(true).load do

  namespace :nginx do
    roles[:nginx]
    roles[:nginx_client]

    set :nginx_init_d, "nginx"
    set :nginx_root, "/opt/nginx"
    set :nginx_conf_path, File.join(File.dirname(__FILE__),'nginx.conf')
    set :nginx_init_d_path, File.join(File.dirname(__FILE__),'nginx.init')
    set :nginx_stub_conf_path, File.join(File.dirname(__FILE__),'stub_status.conf')
    set :nginx_god_path, File.join(File.dirname(__FILE__),'nginx.god')
    set :nginx_logrotate_path, File.join(File.dirname(__FILE__),'nginx.logrotate')
    # must be above 1.1.7 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-1180
    set :nginx_src, "http://nginx.org/download/nginx-1.2.0.tar.gz"
    set(:nginx_ver) { nginx_src.match(/\/([^\/]*)\.tar\.gz$/)[1] }
    set(:nginx_source_dir) {"#{nginx_root}/src/#{nginx_ver}"}
    set(:nginx_patch_dir) {"#{nginx_root}/src"}
    set(:nginx_log_dir) {"#{nginx_root}/logs"}
    set(:nginx_pid_file) {"#{nginx_log_dir}/nginx.pid"}
    set :nginx_watcher, nil
    set :nginx_user, "nobody"
    set :nginx_suppress_runner, false
    set :nginx_port, '80'
    set :nginx_ssl_port, '443'
    set :nginx_bind_eth, nil
    set(:nginx_bind) {"###ETH###" if nginx_bind_eth}
    set(:nginx_listen) {"#{nginx_bind}:#{nginx_port}"}
    set(:nginx_ssl_listen) {"#{nginx_bind}:#{nginx_ssl_port} ssl"}
    set :nginx_server_name, 'localhost'
    set(:nginx_server_names) {nginx_server_name}
    set :nginx_app_conf_path, File.join(File.dirname(__FILE__),'app.conf')
    set :nginx_worker_processes, "1" # should be cpu's - 1
    set(:nginx_app_conf_filename) { application }
    set(:nginx_configure_flags) {[
      "--with-debug",
      "--with-http_gzip_static_module",
      "--with-http_stub_status_module",
      "--with-http_ssl_module",
      "--add-module=#{nginx_patch_dir}/nginx_syslog_patch",
      "--add-module=#{nginx_patch_dir}/nginx-x-rid-header",
      "--with-ld-opt=-lossp-uuid",
      "--with-cc-opt=-I/usr/include/ossp"
    ]}
    set :nginx_cert_name, nil
    set :nginx_cert_path, nil
    set(:nginx_cert_location) { "#{nginx_root}/conf/keys"}
    set :uninstall_apt_nginx, false #false may cause problems with the init.d and leave orhpans, true will destroy the remnants of whatever used to be there.
    set :nginx_redirect_www_to_base_domain, true
    set :nginx_upload_certs, true
    set :nginx_max_fails, "10"
    set :nginx_fail_timeout, "15"
    set :nginx_redirects, nil

    def ipaddress(eth)
      %Q{`ifconfig #{eth} | awk '/inet addr/ {split ($2,A,":"); print A[2]}'`}
    end

    task :upload_certs, :roles => [:web,:nginx,:nginx_client] do
      if nginx_cert_name and nginx_upload_certs
        sudo "mkdir -p #{nginx_cert_location}"
        utilities.sudo_upload_template File.join(nginx_cert_path,"#{nginx_cert_name}.key"), "#{nginx_cert_location}/#{nginx_cert_name}.key"
        utilities.sudo_upload_template File.join(nginx_cert_path,"#{nginx_cert_name}.crt"), "#{nginx_cert_location}/#{nginx_cert_name}.crt"
      end
    end

    desc "select watcher"
    task :watcher do
      nginx.send("watch_with_#{nginx_watcher}".to_sym) unless nginx_watcher.nil?
    end

    desc "Use GOD as nginx's runner"
    task :watch_with_god do
      #rejigger the maintenance tasks to use god when god is in play
      %w(start stop restart).each do |t|
        task t.to_sym, :roles => :web do
          god.cmd "#{t} nginx" unless nginx_suppress_runner
        end
      end
      after "god:setup", "nginx:setup_god"
    end

{'fraction_non_alphanumeric': 0.14728486833816304, 'fraction_numerical': 0.007055562555121583, 'mean_word_length': 3.958151155527795, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2350478', 'n_tokens_mistral': 3049, 'n_tokens_neox': 2995, 'n_words': 540}