pixelforce_kit 0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +299 -0
- data/LICENSE +21 -0
- data/README.md +73 -0
- data/Rakefile +6 -0
- data/app/controllers/admin/api/admin_base_controller.rb +116 -0
- data/app/controllers/admin/api/app_versions_controller.rb +26 -0
- data/app/controllers/admin/api/available_modules_controller.rb +20 -0
- data/app/controllers/api/base_controller.rb +82 -0
- data/app/controllers/api/v1/health_check_controller.rb +12 -0
- data/app/controllers/application_controller.rb +10 -0
- data/app/controllers/auth/passwords_controller.rb +7 -0
- data/app/controllers/concerns/.keep +0 -0
- data/app/controllers/concerns/exception_handler.rb +57 -0
- data/app/controllers/concerns/request_header_handler.rb +35 -0
- data/app/controllers/concerns/response_handler.rb +51 -0
- data/app/controllers/concerns/search_params_parser.rb +35 -0
- data/app/controllers/pages_controller.rb +36 -0
- data/app/controllers/users_controller.rb +3 -0
- data/app/models/ahoy/event.rb +8 -0
- data/app/models/ahoy/visit.rb +6 -0
- data/app/models/application_record.rb +11 -0
- data/app/models/concerns/account_deletable.rb +26 -0
- data/app/models/concerns/assets_uploadable.rb +20 -0
- data/app/models/concerns/codenamable.rb +13 -0
- data/app/models/concerns/image_sizable.rb +58 -0
- data/app/models/concerns/isolationable.rb +18 -0
- data/app/models/concerns/searchable.rb +94 -0
- data/app/models/concerns/taggable.rb +57 -0
- data/app/models/tag.rb +13 -0
- data/app/models/tag_attachable.rb +6 -0
- data/app/models/tag_category.rb +5 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/db/migrate/20220617021719_create_ahoy_visits_and_events.rb +67 -0
- data/db/migrate/20240828040425_create_tags.rb +12 -0
- data/db/migrate/20240828040646_create_tag_attachables.rb +9 -0
- data/db/migrate/20240912054241_create_tag_categories.rb +11 -0
- data/db/schema.rb +24 -0
- data/lib/pixelforce_kit/engine.rb +17 -0
- data/lib/pixelforce_kit/initializer/ahoy.rb +50 -0
- data/lib/pixelforce_kit/railtie.rb +4 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/base.rb +4 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/elbas.rb +10 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/logrotate.rb +10 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/puma.rb +46 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/resque.rb +43 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/resque_scheduler.rb +43 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/sidekiq.rb +88 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/supervisor.rb +9 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/unicorn.rb +58 -0
- data/lib/pixelforce_kit/recipes/templates/logrotate.erb +10 -0
- data/lib/pixelforce_kit/recipes/templates/nginx_config.erb +32 -0
- data/lib/pixelforce_kit/recipes/templates/nginx_puma_config.erb +43 -0
- data/lib/pixelforce_kit/recipes/templates/puma.rb.erb +34 -0
- data/lib/pixelforce_kit/recipes/templates/puma_systemd.erb +19 -0
- data/lib/pixelforce_kit/recipes/templates/resque_init.erb +49 -0
- data/lib/pixelforce_kit/recipes/templates/resque_scheduler_init.erb +49 -0
- data/lib/pixelforce_kit/recipes/templates/resque_scheduler_supervisor.erb +13 -0
- data/lib/pixelforce_kit/recipes/templates/resque_supervisor.erb +13 -0
- data/lib/pixelforce_kit/recipes/templates/sidekiq_init.erb +49 -0
- data/lib/pixelforce_kit/recipes/templates/sidekiq_supervisor.erb +12 -0
- data/lib/pixelforce_kit/recipes/templates/sidekiq_systemd.erb +17 -0
- data/lib/pixelforce_kit/recipes/templates/supervisor.erb +19 -0
- data/lib/pixelforce_kit/recipes/templates/unicorn_init.erb +55 -0
- data/lib/pixelforce_kit/recipes/templates/unicorn_supervisor.erb +13 -0
- data/lib/pixelforce_kit/recipes.rb +4 -0
- data/lib/pixelforce_kit/spec_helper.rb +120 -0
- data/lib/pixelforce_kit/version.rb +3 -0
- data/lib/pixelforce_kit.rb +8 -0
- data/pixelforce_kit.gemspec +33 -0
- metadata +269 -0
data/db/schema.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
ActiveRecord::Schema.define do
|
2
|
+
create_table "users", force: :cascade do |t|
|
3
|
+
t.string :email
|
4
|
+
t.string :provider
|
5
|
+
t.string :country
|
6
|
+
t.string :first_name
|
7
|
+
t.string :last_name
|
8
|
+
t.date :dob
|
9
|
+
t.string :timezone
|
10
|
+
t.datetime :last_visit_at
|
11
|
+
t.boolean :global_notification
|
12
|
+
t.bigint :turned_off_notification_category_ids, array: true
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
|
16
|
+
create_table "admin_users", force: :cascade do |t|
|
17
|
+
t.string :email
|
18
|
+
t.string :first_name
|
19
|
+
t.string :last_name
|
20
|
+
t.string :provider
|
21
|
+
t.boolean :global_notification
|
22
|
+
t.timestamps
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module PixelforceKit
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace PixelforceKit
|
4
|
+
|
5
|
+
initializer :append_migrations do |app|
|
6
|
+
unless app.root.to_s.match root.to_s
|
7
|
+
config.paths["db/migrate"].expanded.each do |expanded_path|
|
8
|
+
ActiveRecord::Migrator.migrations_paths << expanded_path
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
initializer :initializer_ahoy do
|
14
|
+
require_relative 'initializer/ahoy'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class Ahoy::Store < Ahoy::DatabaseStore
|
2
|
+
def track_visit(data)
|
3
|
+
if @cloudfront_headers.present?
|
4
|
+
data[:country] = @cloudfront_headers[:cloudfront_viewer_country_name]
|
5
|
+
data[:region] = @cloudfront_headers[:cloudfront_viewer_country_region_name]
|
6
|
+
data[:city] = @cloudfront_headers[:cloudfront_viewer_city]
|
7
|
+
end
|
8
|
+
super(data)
|
9
|
+
end
|
10
|
+
|
11
|
+
def track_event(data)
|
12
|
+
params = data[:properties][:params].deep_dup
|
13
|
+
sanitized_params = remove_password_params(params)
|
14
|
+
data[:properties][:method] = request.method
|
15
|
+
data[:properties][:params] = sanitized_params
|
16
|
+
data[:user_type] = controller.try('current_user')&.class&.name || controller.try('current_admin_user')&.class&.name
|
17
|
+
data[:user_id] = controller.current_admin_user.id if controller.try('current_admin_user').present?
|
18
|
+
data[:admin_action_on_user_id] = controller.admin_action_on_user_id if controller.try('admin_action_on_user_id').present?
|
19
|
+
data[:cloudfront_headers] = @cloudfront_headers if @cloudfront_headers.present?
|
20
|
+
super(data)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def remove_password_params(params)
|
26
|
+
case params
|
27
|
+
when Hash
|
28
|
+
params.each_with_object({}) do |(key, value), result|
|
29
|
+
if key.to_s == 'controller' || key.to_s == 'action'
|
30
|
+
result[key] = remove_password_params(value)
|
31
|
+
elsif !(key.to_s.downcase.include?('password') || value.to_s.downcase.include?('password'))
|
32
|
+
result[key] = remove_password_params(value)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
when Array
|
36
|
+
params.map { |item| remove_password_params(item) }
|
37
|
+
else
|
38
|
+
params
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# set to true for JavaScript tracking
|
44
|
+
Ahoy.api = true
|
45
|
+
Ahoy.track_bots = true
|
46
|
+
|
47
|
+
# set to true for geocoding (and add the geocoder gem to your Gemfile)
|
48
|
+
# we recommend configuring local geocoding as well
|
49
|
+
# see https://github.com/ankane/ahoy#geocoding
|
50
|
+
Ahoy.geocode = false
|
@@ -0,0 +1,10 @@
|
|
1
|
+
namespace :logrotate do
|
2
|
+
desc "Setup logrotate configuration for this application"
|
3
|
+
task :setup do
|
4
|
+
on roles(:app) do
|
5
|
+
template "logrotate.erb", "/tmp/logrotate"
|
6
|
+
sudo "mv /tmp/logrotate /etc/logrotate.d/#{fetch(:application)}"
|
7
|
+
sudo "chown root:root /etc/logrotate.d/#{fetch(:application)}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
namespace :puma do
|
2
|
+
desc 'Setup puma configuration for this application'
|
3
|
+
task :config do
|
4
|
+
on roles(:web) do
|
5
|
+
template 'puma.rb.erb', '/tmp/puma_conf'
|
6
|
+
sudo "mv /tmp/puma_conf #{shared_path}/config/puma.rb"
|
7
|
+
execute "mkdir -p #{shared_path}/pids"
|
8
|
+
template "nginx_puma_config.erb", "/tmp/nginx_puma_config"
|
9
|
+
sudo "mv /tmp/nginx_puma_config /etc/nginx/sites-enabled/#{fetch(:application)}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
namespace :systemd do
|
14
|
+
task :setup do
|
15
|
+
on roles(:web) do
|
16
|
+
template 'puma_systemd.erb', '/tmp/puma.service'
|
17
|
+
sudo 'mv /tmp/puma.service /etc/systemd/system/puma.service'
|
18
|
+
sudo 'systemctl daemon-reload'
|
19
|
+
sudo 'systemctl enable puma.service'
|
20
|
+
sudo 'systemctl start puma.service'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
task :restart do
|
25
|
+
on roles(:web) do
|
26
|
+
sudo 'systemctl restart puma'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
task :reload do
|
31
|
+
on roles(:web) do
|
32
|
+
sudo 'systemctl reload puma'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
namespace :supervisor do
|
38
|
+
task :uninstall do
|
39
|
+
on roles(:web) do
|
40
|
+
sudo "rm /etc/supervisor/conf.d/#{fetch(:application)}.conf"
|
41
|
+
sudo 'supervisorctl reread'
|
42
|
+
sudo 'supervisorctl update'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
namespace :resque do
|
2
|
+
desc "Install resque"
|
3
|
+
|
4
|
+
desc "Setup resque configuration for this application"
|
5
|
+
namespace :sysvinit do
|
6
|
+
task :setup do
|
7
|
+
on roles(:resque) do
|
8
|
+
template "resque_init.erb", "/tmp/resque"
|
9
|
+
sudo "mv /tmp/resque /etc/init.d/resque"
|
10
|
+
sudo "chmod +x /etc/init.d/resque"
|
11
|
+
sudo "update-rc.d resque defaults"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
%w[start stop restart].each do |command|
|
16
|
+
desc "#{command} resque"
|
17
|
+
task command do
|
18
|
+
on roles(:resque) do
|
19
|
+
execute "/etc/init.d/resque #{command}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
namespace :supervisor do
|
25
|
+
task :setup do
|
26
|
+
on roles(:resque) do
|
27
|
+
template "resque_supervisor.erb", "/tmp/resque"
|
28
|
+
sudo "mv /tmp/resque /etc/supervisor/conf.d/resque.conf"
|
29
|
+
sudo "supervisorctl reread"
|
30
|
+
sudo "supervisorctl update" # it will auto start the application
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
%w[start stop restart].each do |command|
|
35
|
+
desc "#{command} resque"
|
36
|
+
task command do
|
37
|
+
on roles(:resque) do
|
38
|
+
execute "supervisorctl #{command} resque"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
namespace :resque_scheduler do
|
2
|
+
desc "Install resque scheduler"
|
3
|
+
|
4
|
+
desc "Setup resque scheduler configuration for this application"
|
5
|
+
namespace :sysvinit do
|
6
|
+
task :setup do
|
7
|
+
on roles(:resque) do
|
8
|
+
template "resque_scheduler_init.erb", "/tmp/resque_scheduler"
|
9
|
+
sudo "mv /tmp/resque_scheduler /etc/init.d/resque_scheduler"
|
10
|
+
sudo "chmod +x /etc/init.d/resque_scheduler"
|
11
|
+
sudo "update-rc.d resque_scheduler defaults"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
%w[start stop restart].each do |command|
|
16
|
+
desc "#{command} resque_scheduler"
|
17
|
+
task command do
|
18
|
+
on roles(:resque) do
|
19
|
+
execute "/etc/init.d/resque_scheduler #{command}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
namespace :supervisor do
|
25
|
+
task :setup do
|
26
|
+
on roles(:resque) do
|
27
|
+
template "resque_scheduler_supervisor.erb", "/tmp/resque_scheduler"
|
28
|
+
sudo "mv /tmp/resque_scheduler /etc/supervisor/conf.d/resque_scheduler.conf"
|
29
|
+
sudo "supervisorctl reread"
|
30
|
+
sudo "supervisorctl update" # it will auto start the application
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
%w[start stop restart].each do |command|
|
35
|
+
desc "#{command} resque_scheduler"
|
36
|
+
task command do
|
37
|
+
on roles(:resque) do
|
38
|
+
execute "supervisorctl #{command} resque_scheduler"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
namespace :sidekiq do
|
2
|
+
desc 'Install sidekiq'
|
3
|
+
|
4
|
+
namespace :systemd do
|
5
|
+
task :setup do
|
6
|
+
on roles(:app) do
|
7
|
+
template 'sidekiq_systemd.erb', '/tmp/sidekiq.service'
|
8
|
+
sudo 'mv /tmp/sidekiq.service /etc/systemd/system/sidekiq.service'
|
9
|
+
sudo 'systemctl daemon-reload'
|
10
|
+
sudo 'systemctl enable sidekiq'
|
11
|
+
sudo 'systemctl start sidekiq'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
task :unload do
|
16
|
+
on roles(:app) do
|
17
|
+
sudo 'systemctl kill -s TSTP sidekiq'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
task :restart do
|
22
|
+
on roles(:app) do
|
23
|
+
sudo 'systemctl restart sidekiq'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
namespace :supervisor do
|
29
|
+
task :uninstall do
|
30
|
+
on roles(:sidekiq) do
|
31
|
+
sudo 'rm /etc/supervisor/conf.d/sidekiq.conf'
|
32
|
+
sudo 'supervisorctl reread'
|
33
|
+
sudo 'supervisorctl update'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
task :setup do
|
38
|
+
on roles(:sidekiq) do
|
39
|
+
template "sidekiq_supervisor.erb", "/tmp/sidekiq"
|
40
|
+
sudo "mv /tmp/sidekiq /etc/supervisor/conf.d/sidekiq.conf"
|
41
|
+
sudo "supervisorctl reread"
|
42
|
+
sudo "supervisorctl update" # it will auto start the application
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
%w[start stop restart].each do |command|
|
47
|
+
desc "#{command} sidekiq"
|
48
|
+
task command do
|
49
|
+
on roles(:sidekiq) do
|
50
|
+
execute "supervisorctl #{command} sidekiq"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
task :unload do
|
55
|
+
desc "tell sidekiq stop receive new jobs, called at the beginning"
|
56
|
+
on roles(:sidekiq) do
|
57
|
+
execute "supervisorctl signal TSTP sidekiq"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
task :rolling_restart do
|
61
|
+
desc "used for rolling restart, only available on enterprise version"
|
62
|
+
on roles(:sidekiq) do
|
63
|
+
execute "supervisorctl signal USR2 sidekiq"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
%w[start_group stop_group restart_group].each do |command|
|
68
|
+
desc "#{command} sidekiq"
|
69
|
+
task command do
|
70
|
+
on roles(:sidekiq) do
|
71
|
+
execute "supervisorctl #{command.split('_')[0]} sidekiq:*"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
task :unload_group do
|
76
|
+
desc "tell sidekiq stop receive new jobs, called at the beginning"
|
77
|
+
on roles(:sidekiq) do
|
78
|
+
execute "supervisorctl signal TSTP sidekiq:*"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
task :rolling_restart_group do
|
82
|
+
desc "used for rolling restart, only available on enterprise version"
|
83
|
+
on roles(:sidekiq) do
|
84
|
+
execute "supervisorctl signal USR2 sidekiq:*"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
namespace :unicorn do
|
2
|
+
desc "Install unicorn"
|
3
|
+
namespace :sysvinit do
|
4
|
+
task :setup do
|
5
|
+
on roles(:web) do
|
6
|
+
template "unicorn_init.erb", "/tmp/unicorn"
|
7
|
+
sudo "mv /tmp/unicorn /etc/init.d/#{fetch(:application)}"
|
8
|
+
sudo "chmod +x /etc/init.d/#{fetch(:application)}"
|
9
|
+
sudo "update-rc.d #{fetch(:application)} defaults"
|
10
|
+
template "nginx_config.erb", "/tmp/nginx_config"
|
11
|
+
sudo "mv /tmp/nginx_config /etc/nginx/sites-enabled/#{fetch(:application)}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
%w[start stop restart reload].each do |command|
|
16
|
+
desc "#{command} unicorn"
|
17
|
+
task command do
|
18
|
+
on roles(:web) do
|
19
|
+
execute "/etc/init.d/#{fetch(:application)} #{command}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
namespace :supervisor do
|
25
|
+
desc "Setup unicorn configuration for this application"
|
26
|
+
task :setup do
|
27
|
+
on roles(:web) do
|
28
|
+
template "unicorn_supervisor.erb", "/tmp/unicorn"
|
29
|
+
sudo "mv /tmp/unicorn /etc/supervisor/conf.d/#{fetch(:application)}.conf"
|
30
|
+
sudo "supervisorctl reread"
|
31
|
+
sudo "supervisorctl update" # it will auto start the application
|
32
|
+
template "nginx_config.erb", "/tmp/nginx_config"
|
33
|
+
sudo "mv /tmp/nginx_config /etc/nginx/sites-enabled/#{fetch(:application)}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
task :start do
|
38
|
+
on roles(:web) do
|
39
|
+
execute "supervisorctl start #{fetch(:application)}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
task :stop do
|
43
|
+
on roles(:web) do
|
44
|
+
execute "supervisorctl signal QUIT #{fetch(:application)}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
task :restart do
|
48
|
+
on roles(:web) do
|
49
|
+
execute "supervisorctl signal USR2 #{fetch(:application)}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
task :reload do
|
53
|
+
on roles(:web) do
|
54
|
+
execute "supervisorctl signal HUP #{fetch(:application)}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
upstream <%= fetch(:application) %> {
|
2
|
+
server unix:/tmp/<%= fetch(:application) %>.sock fail_timeout=0;
|
3
|
+
}
|
4
|
+
|
5
|
+
server {
|
6
|
+
listen 80;
|
7
|
+
server_name <%= fetch(:server_address) %>;
|
8
|
+
root <%= fetch(:deploy_to) %>/current/public;
|
9
|
+
|
10
|
+
try_files $uri/index.html $uri @<%= fetch(:application) %>;
|
11
|
+
|
12
|
+
location ~* ^(/assets|/favicon.ico) {
|
13
|
+
access_log off;
|
14
|
+
expires max;
|
15
|
+
}
|
16
|
+
|
17
|
+
location @<%= fetch(:application) %> {
|
18
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
19
|
+
proxy_set_header X-Forwarded-Ssl on;
|
20
|
+
proxy_set_header X-Forwarded-Port 443;
|
21
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
22
|
+
proxy_set_header Host $http_host;
|
23
|
+
proxy_redirect off;
|
24
|
+
proxy_buffering on;
|
25
|
+
proxy_set_header X-Real-IP $remote_addr;
|
26
|
+
proxy_pass http://<%= fetch(:application) %>;
|
27
|
+
}
|
28
|
+
|
29
|
+
error_page 500 502 503 504 /500.html;
|
30
|
+
client_max_body_size 1G;
|
31
|
+
keepalive_timeout 10;
|
32
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
upstream <%= fetch(:application) %> {
|
2
|
+
server unix:/tmp/<%= fetch(:application) %>.sock fail_timeout=0;
|
3
|
+
}
|
4
|
+
|
5
|
+
server {
|
6
|
+
listen 80 default_server deferred;
|
7
|
+
server_name <%= fetch(:server_address) %>;
|
8
|
+
|
9
|
+
root <%= fetch(:deploy_to) %>/current/public;
|
10
|
+
|
11
|
+
location ^~ /packs/ {
|
12
|
+
gzip_static on;
|
13
|
+
expires max;
|
14
|
+
add_header Cache-Control public;
|
15
|
+
}
|
16
|
+
|
17
|
+
try_files $uri $uri @<%= fetch(:application) %>;
|
18
|
+
location @<%= fetch(:application) %> {
|
19
|
+
proxy_set_header X-Forwarded-Proto https;
|
20
|
+
proxy_set_header X-Url-Scheme https;
|
21
|
+
proxy_set_header X-Forwarded-Ssl on;
|
22
|
+
proxy_set_header Front-End-Https on;
|
23
|
+
|
24
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
25
|
+
proxy_set_header Host $http_host;
|
26
|
+
proxy_redirect off;
|
27
|
+
proxy_buffering on;
|
28
|
+
proxy_set_header X-Real-IP $remote_addr;
|
29
|
+
|
30
|
+
proxy_pass http://<%= fetch(:application) %>;
|
31
|
+
}
|
32
|
+
|
33
|
+
location /cable {
|
34
|
+
proxy_pass http://<%= fetch(:application) %>;
|
35
|
+
proxy_http_version 1.1;
|
36
|
+
proxy_set_header Upgrade $http_upgrade;
|
37
|
+
proxy_set_header Connection "upgrade";
|
38
|
+
}
|
39
|
+
|
40
|
+
error_page 500 502 503 504 /500.html;
|
41
|
+
client_max_body_size 10M;
|
42
|
+
keepalive_timeout 10;
|
43
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env puma
|
2
|
+
|
3
|
+
directory '<%= current_path %>'
|
4
|
+
rackup '<%= current_path %>/config.ru'
|
5
|
+
environment '<%= fetch(:rails_env, 'production') %>'
|
6
|
+
tag '<%= fetch(:application)%>'
|
7
|
+
pidfile '<%= shared_path %>/pids/puma.pid'
|
8
|
+
state_path '<%= shared_path %>/pids/puma.state'
|
9
|
+
stdout_redirect '<%= shared_path %>/log/<%= fetch(:application)%>.log', '<%= shared_path %>/log/<%= fetch(:application)%>.log', true
|
10
|
+
|
11
|
+
threads <%= fetch(:puma_threads, [0, 1]).join(',')%>
|
12
|
+
|
13
|
+
bind 'unix:///tmp/<%= fetch(:application)%>.sock'
|
14
|
+
|
15
|
+
activate_control_app 'unix://<%= shared_path %>/tmp/sockets/pumactl.sock'
|
16
|
+
|
17
|
+
workers <%= fetch(:puma_workers, 2) %>
|
18
|
+
|
19
|
+
preload_app!
|
20
|
+
|
21
|
+
on_restart do
|
22
|
+
puts 'Refreshing Gemfile'
|
23
|
+
ENV['BUNDLE_GEMFILE'] = '<%= current_path %>/Gemfile'
|
24
|
+
end
|
25
|
+
|
26
|
+
before_fork do
|
27
|
+
ActiveRecord::Base.connection_pool.disconnect!
|
28
|
+
end
|
29
|
+
|
30
|
+
on_worker_boot do
|
31
|
+
ActiveSupport.on_load(:active_record) do
|
32
|
+
ActiveRecord::Base.establish_connection
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
[Unit]
|
2
|
+
Description=Puma HTTP Server
|
3
|
+
After=network.target
|
4
|
+
|
5
|
+
[Service]
|
6
|
+
Type=simple
|
7
|
+
User=<%= fetch(:user) %>
|
8
|
+
WorkingDirectory=<%= fetch(:deploy_to) %>/current
|
9
|
+
|
10
|
+
# Helpful for debugging socket activation, etc.
|
11
|
+
# Environment=PUMA_DEBUG=1
|
12
|
+
|
13
|
+
ExecStart=/bin/bash -l -c 'bundle exec puma -C <%= fetch(:deploy_to) %>/shared/config/puma.rb -e <%= fetch(:rails_env) %>'
|
14
|
+
ExecStop=/bin/bash -l -c 'bundle exec pumactl -F <%= fetch(:deploy_to) %>/shared/config/puma.rb stop'
|
15
|
+
ExecReload=/bin/bash -l -c 'bundle exec pumactl -F <%= fetch(:deploy_to) %>/shared/config/puma.rb phased-restart'
|
16
|
+
Restart=always
|
17
|
+
|
18
|
+
[Install]
|
19
|
+
WantedBy=multi-user.target
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
### BEGIN INIT INFO
|
4
|
+
# Provides: resque
|
5
|
+
# Required-Start: $local_fs $remote_fs $network $syslog
|
6
|
+
# Required-Stop: $local_fs $remote_fs $network $syslog
|
7
|
+
# Default-Start: 2 3 4 5
|
8
|
+
# Default-Stop: 0 1 6
|
9
|
+
# Short-Description: resque worker via init.d
|
10
|
+
# Description: starts resque
|
11
|
+
### END INIT INFO
|
12
|
+
|
13
|
+
USER="<%= fetch(:user) %>"
|
14
|
+
PROJECT_PATH="<%= fetch(:deploy_to) %>"
|
15
|
+
NAME=resque
|
16
|
+
DESC="Resque app for $USER"
|
17
|
+
PID="$PROJECT_PATH/shared/pids/resque.pid"
|
18
|
+
LOGFILE="$PROJECT_PATH/shared/log/resque.log"
|
19
|
+
CD_TO_APP_DIR="cd $PROJECT_PATH/current"
|
20
|
+
|
21
|
+
|
22
|
+
case "$1" in
|
23
|
+
start)
|
24
|
+
START_DAEMON_PROCESS="bundle exec rake RAILS_ENV=<%= fetch(:rails_env) %> QUEUE='*' PIDFILE=$PID BACKGROUND=yes environment resque:work 2>&1 > $LOGFILE"
|
25
|
+
echo -n "Starting $DESC: "
|
26
|
+
if [ `whoami` = 'root' ]; then
|
27
|
+
su - $USER -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS"
|
28
|
+
else
|
29
|
+
/bin/bash -l -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS"
|
30
|
+
fi
|
31
|
+
echo "$NAME."
|
32
|
+
;;
|
33
|
+
stop)
|
34
|
+
STOP_DAEMON_PROCESS="test -f $PID && kill -s QUIT `cat $PID` && rm -f $PID"
|
35
|
+
echo -n "Stopping $DESC: "
|
36
|
+
if [ `whoami` = 'root' ]; then
|
37
|
+
su - $USER -c "$CD_TO_APP_DIR && $STOP_DAEMON_PROCESS"
|
38
|
+
else
|
39
|
+
/bin/bash -l -c "$CD_TO_APP_DIR && $STOP_DAEMON_PROCESS"
|
40
|
+
fi
|
41
|
+
echo "$NAME."
|
42
|
+
;;
|
43
|
+
*)
|
44
|
+
echo "Usage: $NAME {start|stop|restart|reload}" >&2
|
45
|
+
exit 1
|
46
|
+
;;
|
47
|
+
esac
|
48
|
+
|
49
|
+
exit 0
|