digital_heroes_startkit 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +37 -0
- data/Rakefile +36 -0
- data/app/assets/config/digital_heroes_startkit_manifest.js +0 -0
- data/app/assets/javascripts/authorization.coffee +79 -0
- data/app/assets/javascripts/avatar.coffee +16 -0
- data/app/assets/javascripts/datepicker.js +2 -0
- data/app/assets/javascripts/digital_heroes_startkit/cable.js +13 -0
- data/app/assets/javascripts/digital_heroes_startkit/channels/pills.coffee +23 -0
- data/app/assets/javascripts/digital_heroes_startkit/input.coffee +5 -0
- data/app/assets/javascripts/digital_heroes_startkit/pills.coffee +2 -0
- data/app/assets/javascripts/digital_heroes_startkit/snap.svg-min.js +21 -0
- data/app/assets/javascripts/digital_heroes_startkit.js +26 -0
- data/app/assets/javascripts/profile.coffee +53 -0
- data/app/assets/javascripts/profile_geodata.coffee +68 -0
- data/app/assets/javascripts/reg_fields_checkup.coffee +96 -0
- data/app/assets/javascripts/registration.coffee +35 -0
- data/app/assets/javascripts/resurrection.coffee +20 -0
- data/app/channels/application_cable/channel.rb +4 -0
- data/app/channels/application_cable/connection.rb +4 -0
- data/app/channels/pills_channel.rb +10 -0
- data/app/controllers/avatars_controller.rb +11 -0
- data/app/controllers/clients_controller.rb +62 -0
- data/app/controllers/email_access_cards_controller.rb +28 -0
- data/app/controllers/geodata_controller.rb +84 -0
- data/app/controllers/nickname_access_cards_controller.rb +30 -0
- data/app/controllers/oauth_controller.rb +178 -0
- data/app/controllers/openid_controller.rb +124 -0
- data/app/controllers/phone_access_cards_controller.rb +28 -0
- data/app/controllers/profile_controller.rb +114 -0
- data/app/controllers/response_controller.rb +17 -0
- data/app/controllers/start_kit_controller.rb +86 -0
- data/app/controllers/user_cards_controller.rb +305 -0
- data/app/jobs/log_analyzer_job.rb +50 -0
- data/app/jobs/password_resurrection_kill_job.rb +9 -0
- data/app/mailers/admin_mailer.rb +9 -0
- data/app/mailers/client_mailer.rb +3 -0
- data/app/mailers/kreator_mailer.rb +9 -0
- data/app/mailers/manager_mailer.rb +9 -0
- data/app/mailers/prometeus_mailer.rb +16 -0
- data/app/mailers/user_cards_mailer.rb +9 -0
- data/app/models/admin.rb +3 -0
- data/app/models/avatar.rb +23 -0
- data/app/models/city.rb +7 -0
- data/app/models/client.rb +31 -0
- data/app/models/country.rb +7 -0
- data/app/models/delayed_job.rb +20 -0
- data/app/models/email_access_card.rb +30 -0
- data/app/models/kreator.rb +3 -0
- data/app/models/log_error.rb +56 -0
- data/app/models/log_error_type.rb +3 -0
- data/app/models/manager.rb +3 -0
- data/app/models/nickname_access_card.rb +18 -0
- data/app/models/oauth_access_card.rb +38 -0
- data/app/models/phone_access_card.rb +19 -0
- data/app/models/prometeus.rb +50 -0
- data/app/models/user_card.rb +158 -0
- data/app/views/admin_mailer/greetings_email.html.erb +191 -0
- data/app/views/client_mailer/greetings_email.html.erb +191 -0
- data/app/views/kreator_mailer/greetings_email.html.erb +191 -0
- data/app/views/manager_mailer/greetings_email.html.erb +191 -0
- data/app/views/oauth/verify.slim +1 -0
- data/app/views/profile/_add_avatar.slim +12 -0
- data/app/views/profile/_user_profile.slim +95 -0
- data/app/views/profile/index.slim +12 -0
- data/app/views/user_cards/authorization.slim +72 -0
- data/app/views/user_cards/confirmation_but_access_code.slim +7 -0
- data/app/views/user_cards/confirmation_complete.slim +7 -0
- data/app/views/user_cards/registration.slim +86 -0
- data/app/views/user_cards/resurrection.slim +19 -0
- data/app/views/user_cards/resurrection_but_access_code.slim +7 -0
- data/app/views/user_cards/resurrection_no_access_code.slim +7 -0
- data/app/views/user_cards_mailer/email.html.erb +191 -0
- data/app/views/user_cards_mailer/resurrection.html.erb +191 -0
- data/config/initializers/session_manager.rb +2 -0
- data/config/routes.rb +53 -0
- data/lib/access_control.rb +3 -0
- data/lib/digital_heroes_startkit/engine.rb +25 -0
- data/lib/digital_heroes_startkit/version.rb +3 -0
- data/lib/digital_heroes_startkit.rb +5 -0
- data/lib/generators/digital_heroes_startkit/install_generator.rb +61 -0
- data/lib/generators/project/Capfile +36 -0
- data/lib/generators/project/Procfile +3 -0
- data/lib/generators/project/app/assets/stylesheets/application.scss +16 -0
- data/lib/generators/project/app/assets/stylesheets/base/_auth.scss +37 -0
- data/lib/generators/project/app/assets/stylesheets/base/_buttons.scss +62 -0
- data/lib/generators/project/app/assets/stylesheets/base/_checkbox.scss +71 -0
- data/lib/generators/project/app/assets/stylesheets/base/_datepicker.scss +620 -0
- data/lib/generators/project/app/assets/stylesheets/base/_form.scss +81 -0
- data/lib/generators/project/app/assets/stylesheets/base/_notice.scss +14 -0
- data/lib/generators/project/app/assets/stylesheets/base/_pills.scss +39 -0
- data/lib/generators/project/app/assets/stylesheets/base/_profile.scss +67 -0
- data/lib/generators/project/app/assets/stylesheets/base/_reset.scss +49 -0
- data/lib/generators/project/app/assets/stylesheets/base/_social.scss +52 -0
- data/lib/generators/project/app/assets/stylesheets/base/_user.scss +0 -0
- data/lib/generators/project/app/assets/stylesheets/base/_user_avatar.scss +18 -0
- data/lib/generators/project/app/assets/stylesheets/base/styles.scss.txt +35 -0
- data/lib/generators/project/app/assets/stylesheets/plugins/sumoselect.scss +296 -0
- data/lib/generators/project/app/controllers/application_controller.rb +3 -0
- data/lib/generators/project/app/views/layouts/_counts.html.erb +29 -0
- data/lib/generators/project/app/views/layouts/_footer.slim +6 -0
- data/lib/generators/project/app/views/layouts/_head.slim +7 -0
- data/lib/generators/project/app/views/layouts/_header.slim +47 -0
- data/lib/generators/project/app/views/layouts/_mobile_menu.slim +11 -0
- data/lib/generators/project/app/views/layouts/application.slim +26 -0
- data/lib/generators/project/app/views/layouts/mailer.html.erb +13 -0
- data/lib/generators/project/app/views/layouts/mailer.text.erb +1 -0
- data/lib/generators/project/config/application.access.yml +66 -0
- data/lib/generators/project/config/application.db.yml +5 -0
- data/lib/generators/project/config/application.google.yml +3 -0
- data/lib/generators/project/config/application.oauth.yml +135 -0
- data/lib/generators/project/config/application.robokassa.yml +10 -0
- data/lib/generators/project/config/application.sendgrid.yml +3 -0
- data/lib/generators/project/config/application.telegram.yml +22 -0
- data/lib/generators/project/config/application.yml +28 -0
- data/lib/generators/project/config/cable.yml +6 -0
- data/lib/generators/project/config/capistrano.yml +78 -0
- data/lib/generators/project/config/database.yml +52 -0
- data/lib/generators/project/config/deploy/application.secrets.yml +4 -0
- data/lib/generators/project/config/deploy/domain.crt +92 -0
- data/lib/generators/project/config/deploy/domain.key +51 -0
- data/lib/generators/project/config/deploy/nginx.conf +50 -0
- data/lib/generators/project/config/deploy/production.rb +67 -0
- data/lib/generators/project/config/deploy/secrets.yml +32 -0
- data/lib/generators/project/config/deploy/secrets.yml.enc +1 -0
- data/lib/generators/project/config/deploy/secrets.yml.key +1 -0
- data/lib/generators/project/config/deploy/staging.rb +61 -0
- data/lib/generators/project/config/deploy/virgin_conf/database.yml +42 -0
- data/lib/generators/project/config/deploy/virgin_conf/nginx_site.conf +47 -0
- data/lib/generators/project/config/deploy/virgin_conf/nginx_site_ssl.conf +57 -0
- data/lib/generators/project/config/deploy/virgin_conf/postfix.cf +685 -0
- data/lib/generators/project/config/deploy/virgin_conf/production.rb +67 -0
- data/lib/generators/project/config/deploy/virgin_conf/puma.rb +66 -0
- data/lib/generators/project/config/deploy/virgin_sh/capistrano.sh +18 -0
- data/lib/generators/project/config/deploy/virgin_sh/foreman.sh +19 -0
- data/lib/generators/project/config/deploy/virgin_sh/rvm_install.sh +10 -0
- data/lib/generators/project/config/deploy.rb +377 -0
- data/lib/generators/project/config/environments/development.rb +91 -0
- data/lib/generators/project/config/environments/production.rb +142 -0
- data/lib/generators/project/config/initializers/session_store.rb +3 -0
- data/lib/generators/project/config/locales/ru.yml +444 -0
- data/lib/generators/project/db/migrate/10_create_user_cards.rb +19 -0
- data/lib/generators/project/db/migrate/12_create_email_access_cards.rb +15 -0
- data/lib/generators/project/db/migrate/13_create_nickname_access_cards.rb +15 -0
- data/lib/generators/project/db/migrate/14_create_phone_access_cards.rb +16 -0
- data/lib/generators/project/db/migrate/15_create_oauth_access_cards.rb +19 -0
- data/lib/generators/project/db/migrate/1_create_kreators.rb +9 -0
- data/lib/generators/project/db/migrate/21_create_avatars.rb +12 -0
- data/lib/generators/project/db/migrate/30_create_countries.rb +12 -0
- data/lib/generators/project/db/migrate/32_create_cities.rb +12 -0
- data/lib/generators/project/db/migrate/3_create_admins.rb +9 -0
- data/lib/generators/project/db/migrate/44_add_sessions_table.rb +12 -0
- data/lib/generators/project/db/migrate/4_create_managers.rb +10 -0
- data/lib/generators/project/db/migrate/5_create_clients.rb +17 -0
- data/lib/generators/project/db/migrate/60_create_log_error_types.rb +9 -0
- data/lib/generators/project/db/migrate/61_create_log_errors.rb +12 -0
- data/lib/generators/project/db/migrate/78_create_delayed_jobs.rb +22 -0
- data/lib/generators/project/db/seeds.rb +27 -0
- data/lib/generators/project/geodata/cities.csv +25305 -0
- data/lib/generators/project/geodata/countries.csv +250 -0
- data/lib/generators/project/public/401.html +75 -0
- data/lib/generators/project/public/404.html +67 -0
- data/lib/generators/project/public/422.html +67 -0
- data/lib/generators/project/public/500.html +66 -0
- data/lib/generators/project/public/_receiver.html +10 -0
- data/lib/generators/project/public/apple-touch-icon-precomposed.png +0 -0
- data/lib/generators/project/public/apple-touch-icon.png +0 -0
- data/lib/generators/project/public/favicon.ico +0 -0
- data/lib/generators/project/public/robots.txt +1 -0
- data/lib/happy_birthday.rb +5 -0
- data/lib/link.rb +16 -0
- data/lib/oauth/oauth.rb +72 -0
- data/lib/oauth/oauth_fb.rb +48 -0
- data/lib/oauth/oauth_gg.rb +50 -0
- data/lib/oauth/oauth_im.rb +51 -0
- data/lib/oauth/oauth_mr.rb +53 -0
- data/lib/oauth/oauth_vk.rb +3 -0
- data/lib/oauth/oauth_yx.rb +51 -0
- data/lib/openid/openid.rb +46 -0
- data/lib/openid/openid_st.rb +2 -0
- data/lib/phone_cutter.rb +9 -0
- data/lib/response.rb +51 -0
- data/lib/session_manager.rb +47 -0
- data/lib/sms_lib.rb +30 -0
- data/lib/social_networks.rb +328 -0
- data/lib/tasks/digital_heroes_startkit_tasks.rake +83 -0
- data/lib/telegram.rb +33 -0
- metadata +497 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# server-based syntax
|
|
2
|
+
# ======================
|
|
3
|
+
# Defines a single server with a list of roles and multiple properties.
|
|
4
|
+
# You can define all roles on a single server, or split them:
|
|
5
|
+
|
|
6
|
+
# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
|
|
7
|
+
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
|
|
8
|
+
# server 'db.example.com', user: 'deploy', roles: %w{db}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# role-based syntax
|
|
13
|
+
# ==================
|
|
14
|
+
|
|
15
|
+
# Defines a role with one or multiple servers. The primary server in each
|
|
16
|
+
# group is considered to be the first unless any hosts have the primary
|
|
17
|
+
# property set. Specify the username and a domain or IP for the server.
|
|
18
|
+
# Don't use `:all`, it's a meta role.
|
|
19
|
+
|
|
20
|
+
role :app, %w{root@cap_server}
|
|
21
|
+
role :web, %w{root@cap_server}
|
|
22
|
+
role :db, %w{root@cap_server}
|
|
23
|
+
|
|
24
|
+
# role :app, %w{deploy@example.com}, my_property: :my_value
|
|
25
|
+
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
|
|
26
|
+
# role :db, %w{deploy@example.com}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# Configuration
|
|
31
|
+
# =============
|
|
32
|
+
# You can set any configuration variable like in config/deploy.rb
|
|
33
|
+
# These variables are then only loaded and set in this stage.
|
|
34
|
+
# For available Capistrano configuration variables see the documentation page.
|
|
35
|
+
# http://capistranorb.com/documentation/getting-started/configuration/
|
|
36
|
+
# Feel free to add new variables to customise your setup.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# Custom SSH Options
|
|
41
|
+
# ==================
|
|
42
|
+
# You may pass any option but keep in mind that net/ssh understands a
|
|
43
|
+
# limited set of options, consult the Net::SSH documentation.
|
|
44
|
+
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
|
|
45
|
+
#
|
|
46
|
+
# Global options
|
|
47
|
+
# --------------
|
|
48
|
+
# set :ssh_options, {
|
|
49
|
+
# user: 'root',
|
|
50
|
+
# keys: %w(~/.ssh/id_rsa),
|
|
51
|
+
# forward_agent: true,
|
|
52
|
+
# auth_methods: %w(publickey),
|
|
53
|
+
# passphrase: 'pussy'
|
|
54
|
+
# }
|
|
55
|
+
#
|
|
56
|
+
# The server-based syntax can be used to override options:
|
|
57
|
+
# ------------------------------------
|
|
58
|
+
server 'cap_server',
|
|
59
|
+
user: 'root',
|
|
60
|
+
roles: %w{web app},
|
|
61
|
+
ssh_options: {
|
|
62
|
+
keys: %w(~/.ssh/id_rsa),
|
|
63
|
+
forward_agent: true,
|
|
64
|
+
auth_methods: %w(publickey),
|
|
65
|
+
passphrase: 'cap_passphrase'
|
|
66
|
+
}
|
|
67
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
shared_dir = 'cap_shared_path'
|
|
2
|
+
|
|
3
|
+
# Puma can serve each request in a thread from an internal thread pool.
|
|
4
|
+
# The `threads` method setting takes two numbers a minimum and maximum.
|
|
5
|
+
# Any libraries that use thread pools should be configured to match
|
|
6
|
+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
|
7
|
+
# and maximum, this matches the default thread size of Active Record.
|
|
8
|
+
#
|
|
9
|
+
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
|
|
10
|
+
threads threads_count, threads_count
|
|
11
|
+
|
|
12
|
+
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
|
|
13
|
+
#
|
|
14
|
+
# port ENV.fetch("PORT") { 80 }
|
|
15
|
+
|
|
16
|
+
# Specifies the `environment` that Puma will run in.
|
|
17
|
+
#
|
|
18
|
+
environment ENV.fetch("RAILS_ENV") { "production" }
|
|
19
|
+
|
|
20
|
+
# Specifies the number of `workers` to boot in clustered mode.
|
|
21
|
+
# Workers are forked webserver processes. If using threads and workers together
|
|
22
|
+
# the concurrency of the application would be max `threads` * `workers`.
|
|
23
|
+
# Workers do not work on JRuby or Windows (both of which do not support
|
|
24
|
+
# processes).
|
|
25
|
+
#
|
|
26
|
+
workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
|
27
|
+
|
|
28
|
+
# Use the `preload_app!` method when specifying a `workers` number.
|
|
29
|
+
# This directive tells Puma to first boot the application and load code
|
|
30
|
+
# before forking the application. This takes advantage of Copy On Write
|
|
31
|
+
# process behavior so workers use less memory. If you use this option
|
|
32
|
+
# you need to make sure to reconnect any threads in the `on_worker_boot`
|
|
33
|
+
# block.
|
|
34
|
+
#
|
|
35
|
+
preload_app!
|
|
36
|
+
|
|
37
|
+
# The code in the `on_worker_boot` will be called if you are using
|
|
38
|
+
# clustered mode by specifying a number of `workers`. After each worker
|
|
39
|
+
# process is booted this block will be run, if you are using `preload_app!`
|
|
40
|
+
# option you will want to use this block to reconnect to any threads
|
|
41
|
+
# or connections that may have been created at application boot, Ruby
|
|
42
|
+
# cannot share connections between processes.
|
|
43
|
+
#
|
|
44
|
+
# on_worker_boot do
|
|
45
|
+
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
|
46
|
+
# end
|
|
47
|
+
|
|
48
|
+
# Set up socket location
|
|
49
|
+
bind "unix://#{shared_dir}/sockets/puma.sock"
|
|
50
|
+
|
|
51
|
+
# Logging
|
|
52
|
+
stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true
|
|
53
|
+
|
|
54
|
+
# Set master PID and state locations
|
|
55
|
+
pidfile "#{shared_dir}/pids/puma.pid"
|
|
56
|
+
state_path "#{shared_dir}/pids/puma.state"
|
|
57
|
+
activate_control_app
|
|
58
|
+
|
|
59
|
+
on_worker_boot do
|
|
60
|
+
require "active_record"
|
|
61
|
+
ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
|
|
62
|
+
ActiveRecord::Base.establish_connection(YAML.load_file("#{shared_dir}/config/database.yml")['production'])
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Allow puma to be restarted by `rails restart` command.
|
|
66
|
+
plugin :tmp_restart
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
domain='cap_server'
|
|
3
|
+
# Вставить Ключ Зажигания
|
|
4
|
+
ssh-copy-id "root@$domain"
|
|
5
|
+
# копирование пакетных файлов
|
|
6
|
+
scp rvm_install.sh "root@$domain":/root
|
|
7
|
+
# Установка RVM - создание среды для возможности действий CAPISTRANO
|
|
8
|
+
ssh "root@$domain" bash rvm_install.sh
|
|
9
|
+
echo "- Товарищ Капитан ! $domain к Деплою Готов !"
|
|
10
|
+
echo '- К Деплою приступить !'
|
|
11
|
+
echo '- Есть !'
|
|
12
|
+
# Инсталляция окружения и Деплой !
|
|
13
|
+
cap production deploy:setup
|
|
14
|
+
cap production deploy
|
|
15
|
+
# Настройка Foreman
|
|
16
|
+
scp foreman.sh "root@$domain":/root
|
|
17
|
+
#ssh "root@$domain" bash foreman.sh
|
|
18
|
+
echo 'для завершения установки зайди на root и запусти foreman.sh'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Экспорт Procfile
|
|
3
|
+
cd /home/rails/cap_application/current
|
|
4
|
+
foreman export systemd /etc/systemd/system --user=root --app=cap_application
|
|
5
|
+
# Замена пути
|
|
6
|
+
files=(/etc/systemd/system/cap_application-web@.service /etc/systemd/system/cap_application-worker@.service /etc/systemd/system/cap_application-redis@.service)
|
|
7
|
+
|
|
8
|
+
for file in ${files[@]}
|
|
9
|
+
do
|
|
10
|
+
if [ -e ${file} ]
|
|
11
|
+
then
|
|
12
|
+
sed -i "s/releases.*$/current/g" ${file}
|
|
13
|
+
echo ${file}
|
|
14
|
+
fi
|
|
15
|
+
done
|
|
16
|
+
|
|
17
|
+
unset files
|
|
18
|
+
|
|
19
|
+
systemctl enable cap_application.target
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# update репозиториев
|
|
3
|
+
apt-get -y update
|
|
4
|
+
apt-get -y install zip
|
|
5
|
+
# установка RVM
|
|
6
|
+
apt install curl
|
|
7
|
+
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
|
|
8
|
+
curl -sSL https://get.rvm.io | bash -s stable
|
|
9
|
+
source /etc/profile.d/rvm.sh
|
|
10
|
+
rvm reinstall ruby-cap_ruby_version
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# config valid only for current version of Capistrano
|
|
2
|
+
lock '3.8.1'
|
|
3
|
+
|
|
4
|
+
# загрузка конфига в полноценный символьный хэш
|
|
5
|
+
require 'active_support/core_ext/hash'
|
|
6
|
+
CONFIG = YAML.load_file(File.expand_path('../capistrano.yml', __FILE__)).with_indifferent_access
|
|
7
|
+
|
|
8
|
+
set :application, CONFIG[:conf][:vars][:cap_application]
|
|
9
|
+
set :repo_url, "git@bitbucket.org:slowpokesfrommoscow/#{fetch :application}.git"
|
|
10
|
+
# set :repo_url, 'git@example.com:me/my_repo.git'
|
|
11
|
+
# Default branch is :master
|
|
12
|
+
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
|
|
13
|
+
|
|
14
|
+
# Default deploy_to directory is /var/www/my_app_name
|
|
15
|
+
set :deploy_to, "/home/rails/#{fetch :application}"
|
|
16
|
+
|
|
17
|
+
# Default value for :format is :airbrussh.
|
|
18
|
+
# set :format, :airbrussh
|
|
19
|
+
|
|
20
|
+
# You can configure the Airbrussh format using :format_options.
|
|
21
|
+
# These are the defaults.
|
|
22
|
+
set :format_options, command_output: true, log_file: 'log/capistrano.log', color: :auto, truncate: :auto
|
|
23
|
+
|
|
24
|
+
# Default value for :pty is false
|
|
25
|
+
# set :pty, true
|
|
26
|
+
# set :default_shell, '/bin/bash -l'
|
|
27
|
+
|
|
28
|
+
# Default value for :linkedlinked_files is []
|
|
29
|
+
# 'config/sitemap.rb',
|
|
30
|
+
set :linked_files, fetch(:linked_files, []).push('config/secrets.yml.enc', 'config/secrets.yml.key', 'config/database.yml', 'config/secrets.yml', 'config/puma.rb')
|
|
31
|
+
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system', 'public', 'files', 'documents')
|
|
32
|
+
|
|
33
|
+
# Default value for default_env is {}
|
|
34
|
+
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
|
35
|
+
|
|
36
|
+
# Default value for keep_releases is 5
|
|
37
|
+
set :keep_releases, 2
|
|
38
|
+
|
|
39
|
+
# Puma:
|
|
40
|
+
# set :puma_conf, "#{shared_path}/config/puma.rb"
|
|
41
|
+
|
|
42
|
+
before 'rvm:hook', 'prepare:ssh'
|
|
43
|
+
|
|
44
|
+
namespace :install do
|
|
45
|
+
desc 'подготовительные мероприятия'
|
|
46
|
+
task :prepare do
|
|
47
|
+
on roles(:all) do
|
|
48
|
+
CONFIG[:soft][:prepare].each do |command|
|
|
49
|
+
execute command
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
desc 'apt'
|
|
55
|
+
task :apt do
|
|
56
|
+
on roles(:all) do
|
|
57
|
+
CONFIG[:soft][:apt].each do |software|
|
|
58
|
+
execute "apt-get -y install #{software}"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
desc 'команды'
|
|
64
|
+
task :commands do
|
|
65
|
+
on roles(:all) do
|
|
66
|
+
CONFIG[:soft][:commands].each do |command|
|
|
67
|
+
execute command
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
desc 'гемы'
|
|
73
|
+
task :gems do
|
|
74
|
+
on roles(:all) do
|
|
75
|
+
CONFIG[:soft][:gems].each do |gem|
|
|
76
|
+
execute "/usr/local/rvm/bin/rvm all do gem install --no-rdoc --no-ri #{gem}"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
namespace :conf do
|
|
84
|
+
|
|
85
|
+
desc 'перемещение кофн файлов на сервак'
|
|
86
|
+
task :copy do
|
|
87
|
+
on roles(:all) do
|
|
88
|
+
# конфиги
|
|
89
|
+
p 'перемещение кофн файлов на сервак'
|
|
90
|
+
upload! 'config/deploy/puma.rb', "#{shared_path}/config/puma.rb"
|
|
91
|
+
upload! 'config/deploy/database.yml', "#{shared_path}/config/database.yml"
|
|
92
|
+
upload! 'config/secrets.yml', "#{shared_path}/config/secrets.yml"
|
|
93
|
+
upload! 'config/deploy/secrets.yml.key', "#{shared_path}/config/secrets.yml.key"
|
|
94
|
+
upload! 'config/deploy/secrets.yml.enc', "#{shared_path}/config/secrets.yml.enc"
|
|
95
|
+
upload! 'config/deploy/application.secrets.yml', "#{shared_path}/config/application.secrets.yml"
|
|
96
|
+
upload! 'config/deploy/foreman.sh', "#{shared_path}/foreman.sh"
|
|
97
|
+
# upload! 'config/deploy/postfix.cf', "/etc/postfix/main.cf"
|
|
98
|
+
upload! 'config/sitemap.rb', "#{shared_path}/config/sitemap.rb"
|
|
99
|
+
|
|
100
|
+
# конфиги NGINX
|
|
101
|
+
upload! 'config/deploy/nginx.conf', "/etc/nginx/nginx.conf"
|
|
102
|
+
# дефолтный конфиг убирается
|
|
103
|
+
execute :rm, "-f /etc/nginx/sites-enabled/default"
|
|
104
|
+
|
|
105
|
+
if CONFIG[:conf][:with_ssl]
|
|
106
|
+
upload! 'config/deploy/nginx_site_ssl.conf', "/etc/nginx/sites-enabled/#{fetch :application}.conf"
|
|
107
|
+
upload! "config/deploy/#{fetch :application}.crt", "/etc/ssl/#{fetch :application}.crt"
|
|
108
|
+
upload! "config/deploy/#{fetch :application}.key", "/etc/ssl/#{fetch :application}.key"
|
|
109
|
+
else
|
|
110
|
+
upload! 'config/deploy/nginx_site.conf', "/etc/nginx/sites-enabled/#{fetch :application}.conf"
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
desc 'добавление SSL к уже работающему проекту'
|
|
116
|
+
task :ssl_update do
|
|
117
|
+
|
|
118
|
+
execute :rake, 'cap:conf_update'
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
on roles(:all) do
|
|
122
|
+
upload! 'config/deploy/nginx_site_ssl.conf', "/etc/nginx/sites-enabled/#{fetch :application}.conf"
|
|
123
|
+
upload! "config/deploy/#{fetch :application}.crt", "/etc/ssl/#{fetch :application}.crt"
|
|
124
|
+
upload! "config/deploy/#{fetch :application}.key", "/etc/ssl/#{fetch :application}.key"
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
invoke 'conf:reload'
|
|
128
|
+
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
desc 'перезапуск нужных сервисов и чек конфига'
|
|
132
|
+
task :reload do
|
|
133
|
+
on roles(:all) do
|
|
134
|
+
execute :systemctl, :restart, :nginx
|
|
135
|
+
execute :systemctl, :restart, :postfix
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
desc 'тесты конфигов, тестовое письмо'
|
|
140
|
+
task :test do
|
|
141
|
+
on roles(:all) do
|
|
142
|
+
execute :nginx, '-t'
|
|
143
|
+
# execute "echo 'Привет! Как дела ?' | mail -s 'Тест от #{CONFIG[:conf][:vars][:cap_domain]}' shadows.of.unevenness@gmail.com"
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
namespace :sitemap do
|
|
149
|
+
desc 'unpack xml'
|
|
150
|
+
task :unpack_xml do
|
|
151
|
+
on roles(:all) do
|
|
152
|
+
within release_path do
|
|
153
|
+
execute "gunzip -c #{shared_path}/public/sitemap.xml.gz > #{shared_path}/public/sitemap.xml"
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
desc 'upload xml'
|
|
159
|
+
task :upload_xml do
|
|
160
|
+
on roles(:all) do
|
|
161
|
+
upload! 'public/sitemap.xml', "#{shared_path}/public"
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
desc 'заливка sitemap.rb'
|
|
166
|
+
task :upload_conf do
|
|
167
|
+
on roles(:all) do
|
|
168
|
+
upload! 'config/sitemap.rb', "#{shared_path}/config"
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
desc 'скачивание файла sitemap.xml почитать'
|
|
173
|
+
task :download_xml do
|
|
174
|
+
on roles(:all) do
|
|
175
|
+
download! "#{shared_path}/public/sitemap.xml", '/Users/nikolajmartynov/Documents/Разработка/Rails/science/public/sitemap.xml'
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
before 'sitemap:create', 'sitemap:upload_conf'
|
|
180
|
+
before 'sitemap:refresh', 'sitemap:upload_conf'
|
|
181
|
+
after 'sitemap:create', 'sitemap:unpack_xml'
|
|
182
|
+
after 'sitemap:create', 'sitemap:download_xml'
|
|
183
|
+
after 'sitemap:refresh', 'sitemap:unpack_xml'
|
|
184
|
+
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
namespace :robots_etc do
|
|
188
|
+
desc 'заливка robots.txt и всяких 404.html'
|
|
189
|
+
task :install do
|
|
190
|
+
on roles(:all) do
|
|
191
|
+
upload! 'public/robots.txt', "#{shared_path}/public"
|
|
192
|
+
upload! 'public/401.html', "#{shared_path}/public"
|
|
193
|
+
upload! 'public/422.html', "#{shared_path}/public"
|
|
194
|
+
upload! 'public/404.html', "#{shared_path}/public"
|
|
195
|
+
upload! 'public/500.html', "#{shared_path}/public"
|
|
196
|
+
upload! 'public/map', "#{shared_path}/public", recursive: true
|
|
197
|
+
upload! 'public/favicon.ico', "#{shared_path}/public"
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
namespace :prepare do
|
|
203
|
+
desc 'проверка там ли ключик ?'
|
|
204
|
+
task :ssh do
|
|
205
|
+
on roles(:all) do
|
|
206
|
+
begin
|
|
207
|
+
execute "ssh -o PasswordAuthentication=no root@#{CONFIG[:conf][:vars][:cap_server]}"
|
|
208
|
+
rescue
|
|
209
|
+
p 'ТВОЙ КЛЮЧ ЕЩЁ НЕ НА СЕРВАКЕ, ВВЕДИ РУТОВЫЙ ПАРОЛЬ!'
|
|
210
|
+
# копирование ключа на сервак
|
|
211
|
+
`ssh-copy-id root@#{CONFIG[:conf][:vars][:cap_server]}`
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# плавный запуск ssh-agent'а для комфортного деплоя, и чтобы не заёбывал каждый раз, предусмотрена проверка .)
|
|
215
|
+
if /no identities/ =~ `ssh-add -l`
|
|
216
|
+
`eval 'ssh-agent'`
|
|
217
|
+
`ssh-add`
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
namespace :log do
|
|
225
|
+
desc 'скачивание логов'
|
|
226
|
+
|
|
227
|
+
task :dwnld do
|
|
228
|
+
on roles(:all) do
|
|
229
|
+
download! "#{shared_path}/log/production.log", "/Users/nikolajmartynov/Documents/Разработка/Rails/#{CONFIG[:conf][:vars][:cap_application]}/log/production.log"
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
namespace :feed do
|
|
236
|
+
desc 'заливка тестового xml'
|
|
237
|
+
task :upload do
|
|
238
|
+
on roles(:all) do
|
|
239
|
+
upload! 'public/feed.xml', "#{shared_path}/public"
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
namespace :db do
|
|
245
|
+
desc 'db fuck!'
|
|
246
|
+
task :fuck do
|
|
247
|
+
on roles(:all) do
|
|
248
|
+
within release_path do
|
|
249
|
+
with rails_env: fetch(:rails_env) do
|
|
250
|
+
execute :rake, 'db:fuck'
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
namespace :database do
|
|
258
|
+
|
|
259
|
+
task :create do
|
|
260
|
+
on roles(:all) do
|
|
261
|
+
within release_path do
|
|
262
|
+
with rails_env: fetch(:rails_env) do
|
|
263
|
+
execute :rake, 'db:create'
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
namespace :dump do
|
|
272
|
+
desc 'загрузить дамп'
|
|
273
|
+
task :upload do
|
|
274
|
+
on roles(:all) do
|
|
275
|
+
upload! 'dump.sql', "#{release_path}"
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
namespace :deploy do
|
|
281
|
+
|
|
282
|
+
task :seed do
|
|
283
|
+
on roles(:all) do
|
|
284
|
+
within release_path do
|
|
285
|
+
with rails_env: fetch(:rails_env) do
|
|
286
|
+
execute :rake, 'db:seed'
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
task :mk_dirs do
|
|
293
|
+
on roles(:all) do
|
|
294
|
+
|
|
295
|
+
execute "mkdir -p #{shared_path} #{shared_path}/config #{shared_path}/pids #{shared_path}/sockets #{shared_path}/log"
|
|
296
|
+
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
task :setup do
|
|
302
|
+
on roles(:all) do
|
|
303
|
+
|
|
304
|
+
# invoke 'deploy:mk_dirs'
|
|
305
|
+
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
task :prepare do
|
|
311
|
+
|
|
312
|
+
invoke 'deploy:mk_dirs'
|
|
313
|
+
execute :rake, 'cap:conf_update'
|
|
314
|
+
invoke 'conf:copy'
|
|
315
|
+
invoke 'conf:reload'
|
|
316
|
+
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
before 'deploy:assets:precompile', 'database:create'
|
|
320
|
+
|
|
321
|
+
after 'deploy:setup', 'install:prepare'
|
|
322
|
+
after 'deploy:setup', 'install:apt'
|
|
323
|
+
after 'deploy:setup', 'install:commands'
|
|
324
|
+
after 'deploy:setup', 'install:gems'
|
|
325
|
+
after 'deploy:setup', 'deploy:prepare'
|
|
326
|
+
after 'deploy:setup', 'conf:test'
|
|
327
|
+
|
|
328
|
+
after :deploy, 'robots_etc:install'
|
|
329
|
+
after :deploy, 'deploy:seed'
|
|
330
|
+
after :deploy, 'app:reload'
|
|
331
|
+
# after :deploy, 'sitemap:refresh'
|
|
332
|
+
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
namespace :app do
|
|
336
|
+
desc 'Start server'
|
|
337
|
+
task :start do
|
|
338
|
+
on roles(:all) do
|
|
339
|
+
execute "systemctl start #{fetch :application}.target"
|
|
340
|
+
end
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
desc 'Stop server'
|
|
344
|
+
task :stop do
|
|
345
|
+
on roles(:all) do
|
|
346
|
+
execute "systemctl stop #{fetch :application}.target"
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
desc 'Server status'
|
|
352
|
+
task :status do
|
|
353
|
+
on roles(:all) do
|
|
354
|
+
execute "systemctl status #{fetch :application}.target"
|
|
355
|
+
execute 'systemctl status nginx'
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
desc 'Server reload'
|
|
360
|
+
task :reload do
|
|
361
|
+
on roles(:all) do
|
|
362
|
+
execute 'systemctl daemon-reload'
|
|
363
|
+
invoke 'app:stop'
|
|
364
|
+
invoke 'app:start'
|
|
365
|
+
end
|
|
366
|
+
end
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
def err path
|
|
370
|
+
p '===S=====T========P==============='
|
|
371
|
+
p '=====h=i====H=a=p===E============='
|
|
372
|
+
p '======================N=S=!======='
|
|
373
|
+
p "#{path} NOT FOUND"
|
|
374
|
+
p '=================================='
|
|
375
|
+
p '=================================='
|
|
376
|
+
p '=================================='
|
|
377
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Rails.application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# не требуется железной связи!
|
|
6
|
+
Rails.application.config.active_record.belongs_to_required_by_default = false
|
|
7
|
+
|
|
8
|
+
config.time_zone = 'Moscow'
|
|
9
|
+
config.active_record.default_timezone = :local
|
|
10
|
+
config.action_mailer.default_url_options = { :host => CONFIG[:domain] }
|
|
11
|
+
|
|
12
|
+
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s]
|
|
13
|
+
config.i18n.default_locale = :ru
|
|
14
|
+
config.encoding = 'utf-8'
|
|
15
|
+
|
|
16
|
+
config.active_job.queue_adapter = :delayed_job
|
|
17
|
+
|
|
18
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
|
19
|
+
|
|
20
|
+
config.action_view.embed_authenticity_token_in_remote_forms = true
|
|
21
|
+
|
|
22
|
+
config.after_initialize do
|
|
23
|
+
Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'dj.log'))
|
|
24
|
+
|
|
25
|
+
begin
|
|
26
|
+
# запуск jobs
|
|
27
|
+
if ActiveRecord::Migrator.get_all_versions.any?
|
|
28
|
+
Delayed::Backend::ActiveRecord::Job.where(queue: :log_analyzer).destroy_all
|
|
29
|
+
|
|
30
|
+
LogAnalyzerJob.set(wait_until: DateTime.now).perform_later
|
|
31
|
+
end
|
|
32
|
+
# уничтожение сессий
|
|
33
|
+
ActiveRecord::SessionStore::Session.delete_all
|
|
34
|
+
rescue Exception => error
|
|
35
|
+
p error.message
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# In the development environment your application's code is reloaded on
|
|
42
|
+
# every request. This slows down response time but is perfect for development
|
|
43
|
+
# since you don't have to restart the web server when you make code changes.
|
|
44
|
+
config.cache_classes = false
|
|
45
|
+
|
|
46
|
+
# Do not eager load code on boot.
|
|
47
|
+
config.eager_load = false
|
|
48
|
+
|
|
49
|
+
# Show full error reports.
|
|
50
|
+
config.consider_all_requests_local = true
|
|
51
|
+
|
|
52
|
+
# Enable/disable caching. By default caching is disabled.
|
|
53
|
+
if Rails.root.join('tmp/caching-dev.txt').exist?
|
|
54
|
+
config.action_controller.perform_caching = true
|
|
55
|
+
|
|
56
|
+
config.cache_store = :memory_store
|
|
57
|
+
config.public_file_server.headers = {
|
|
58
|
+
'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
|
|
59
|
+
}
|
|
60
|
+
else
|
|
61
|
+
config.action_controller.perform_caching = false
|
|
62
|
+
|
|
63
|
+
config.cache_store = :null_store
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Don't care if the mailer can't send.
|
|
67
|
+
config.action_mailer.raise_delivery_errors = false
|
|
68
|
+
|
|
69
|
+
config.action_mailer.perform_caching = false
|
|
70
|
+
|
|
71
|
+
# Print deprecation notices to the Rails logger.
|
|
72
|
+
config.active_support.deprecation = :log
|
|
73
|
+
|
|
74
|
+
# Raise an error on page load if there are pending migrations.
|
|
75
|
+
config.active_record.migration_error = :page_load
|
|
76
|
+
|
|
77
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
|
78
|
+
# This option may cause significant delays in view rendering with a large
|
|
79
|
+
# number of complex assets.
|
|
80
|
+
config.assets.debug = true
|
|
81
|
+
|
|
82
|
+
# Suppress logger output for asset requests.
|
|
83
|
+
config.assets.quiet = true
|
|
84
|
+
|
|
85
|
+
# Raises error for missing translations
|
|
86
|
+
# config.action_view.raise_on_missing_translations = true
|
|
87
|
+
|
|
88
|
+
# Use an evented file watcher to asynchronously detect changes in source code,
|
|
89
|
+
# routes, locales, etc. This feature depends on the listen gem.
|
|
90
|
+
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
|
91
|
+
end
|