enjoy_cms 0.3.7.4 → 0.4.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +62 -111
- data/app/assets/javascripts/{enjoy_cms → enjoy/cms}/flash.coffee +0 -0
- data/app/assets/javascripts/enjoy/cms/init.coffee +1 -0
- data/app/assets/javascripts/{enjoy_cms → enjoy/cms}/map.coffee +0 -0
- data/app/assets/javascripts/enjoy/cms.coffee +11 -0
- data/app/assets/javascripts/enjoy/rails_admin/cms.ui.coffee +26 -0
- data/app/assets/javascripts/{enjoy_cms → enjoy}/rails_admin/custom/ui.coffee +0 -0
- data/app/assets/javascripts/rails_admin/custom/ui.coffee +2 -2
- data/app/assets/stylesheets/{enjoy_cms → enjoy/cms}/flash.sass +0 -0
- data/app/assets/stylesheets/{enjoy_cms → enjoy/cms}/normalize.scss +0 -0
- data/app/assets/stylesheets/{enjoy_cms → enjoy/cms}/powered.sass +0 -0
- data/app/assets/stylesheets/{enjoy_cms.sass → enjoy/cms.sass} +3 -1
- data/app/assets/stylesheets/enjoy/rails_admin/cms.ui.sass +117 -0
- data/{lib/enjoy/controllers/sitemap_data.rb → app/assets/stylesheets/enjoy/rails_admin/custom/ui.sass} +0 -0
- data/app/assets/stylesheets/rails_admin/custom/theming.sass +2 -0
- data/app/controllers/concerns/enjoy/errors.rb +1 -1
- data/app/controllers/enjoy/registrations_controller.rb +20 -0
- data/app/controllers/enjoy/sessions_controller.rb +19 -0
- data/app/helpers/enjoy/home_helper.rb +2 -0
- data/app/helpers/enjoy/powered_helper.rb +1 -1
- data/app/models/concerns/enjoy/html_field.rb +3 -0
- data/app/views/blocks/_favicon.html.slim +60 -21
- data/app/views/devise/registrations/edit.html.slim +2 -2
- data/app/views/devise/registrations/new.html.slim +9 -3
- data/app/views/devise/sessions/new.html.slim +8 -2
- data/app/views/devise/shared/_links.html.slim +4 -4
- data/app/views/{errors → enjoy/errors}/_base.html.slim +0 -0
- data/app/views/{errors → enjoy/errors}/error_403.html.slim +0 -0
- data/app/views/{errors → enjoy/errors}/error_404.html.slim +0 -0
- data/app/views/{errors → enjoy/errors}/error_500.html.slim +0 -0
- data/app/views/{simple_captcha → enjoy/simple_captcha}/_simple_captcha.html.slim +0 -0
- data/app/views/layouts/application.html.slim +8 -4
- data/app/views/layouts/enjoy/devise/confirmations.html.slim +27 -0
- data/app/views/layouts/enjoy/devise/passwords.html.slim +27 -0
- data/app/views/layouts/enjoy/devise/registrations.html.slim +27 -0
- data/app/views/layouts/enjoy/devise/sessions.html.slim +27 -0
- data/app/views/layouts/enjoy/devise/unlocks.html.slim +27 -0
- data/app/views/rails_admin/main/_setting_value.html.haml +104 -0
- data/app/views/shared/_messages.html.slim +1 -1
- data/config/initializers/simple_captcha.rb +29 -20
- data/config/locales/en.enjoy.yml +1 -1
- data/config/locales/ru.enjoy.yml +0 -7
- data/config/locales/ru.models.yml +2 -39
- data/enjoy_cms.gemspec +7 -20
- data/lib/enjoy/configuration.rb +24 -40
- data/lib/enjoy/controller.rb +5 -3
- data/lib/enjoy/engine.rb +28 -28
- data/lib/enjoy/migration.rb +0 -19
- data/lib/enjoy/model.rb +5 -2
- data/lib/enjoy/rails_admin_ext/config.rb +112 -0
- data/lib/enjoy/rails_admin_ext/enjoy_hash.rb +0 -2
- data/lib/enjoy/rails_admin_ext/enjoy_slugs.rb +31 -0
- data/lib/enjoy/rails_admin_ext/group_patch.rb +2 -1
- data/lib/enjoy/rails_admin_settings_patch.rb +7 -0
- data/lib/enjoy/routes.rb +1 -26
- data/lib/enjoy/version.rb +1 -1
- data/lib/enjoy_cms.rb +25 -71
- data/lib/filename_to_slug.rb +20 -22
- data/lib/generators/enjoy/{ability_generator.rb → cms/ability_generator.rb} +3 -3
- data/lib/generators/enjoy/{admin_generator.rb → cms/admin_generator.rb} +2 -2
- data/lib/generators/enjoy/cms/application_generator.rb +14 -0
- data/lib/generators/enjoy/cms/assets_generator.rb +35 -0
- data/lib/generators/enjoy/{config/install_generator.rb → cms/config_generator.rb} +3 -3
- data/lib/generators/enjoy/cms/gemfile_generator.rb +13 -0
- data/lib/generators/enjoy/{layout_generator.rb → cms/layout_generator.rb} +2 -2
- data/lib/generators/enjoy/cms/paperclip_optimizer_generator.rb +13 -0
- data/lib/generators/enjoy/cms/rack_generator.rb +12 -0
- data/lib/generators/enjoy/cms/robots_generator.rb +12 -0
- data/lib/generators/enjoy/cms/scripts_generator.rb +25 -0
- data/lib/generators/enjoy/cms/templates/Gemfile.erb +69 -0
- data/lib/generators/enjoy/cms/templates/ability.erb +45 -0
- data/lib/generators/enjoy/{templates → cms/templates}/admin.erb +5 -26
- data/lib/generators/enjoy/cms/templates/application.erb +42 -0
- data/lib/generators/enjoy/cms/templates/assets/javascripts/application.coffee.erb +1 -0
- data/lib/generators/enjoy/cms/templates/assets/stylesheets/application.sass.erb +15 -0
- data/lib/generators/enjoy/cms/templates/assets/stylesheets/enjoy/rails_admin/custom/ui.sass.erb +106 -0
- data/lib/generators/enjoy/cms/templates/enjoy_cms.erb +28 -0
- data/lib/generators/enjoy/cms/templates/paperclip_optimizer.erb +80 -0
- data/lib/generators/enjoy/cms/templates/rack.erb +15 -0
- data/lib/generators/enjoy/cms/templates/robots.txt.erb +4 -0
- data/lib/generators/enjoy/cms/templates/scripts/assets_precompile.sh +3 -0
- data/lib/generators/enjoy/cms/templates/scripts/bundle_production.sh +4 -0
- data/lib/generators/enjoy/cms/templates/scripts/db_dump.sh.erb +3 -0
- data/lib/generators/enjoy/cms/templates/scripts/db_restore.sh +3 -0
- data/lib/generators/enjoy/cms/templates/scripts/full_assets_precompile.sh +4 -0
- data/lib/generators/enjoy/cms/templates/scripts/restart_thru_kill.sh +3 -0
- data/lib/generators/enjoy/cms/templates/scripts/send_hup.sh +3 -0
- data/lib/generators/enjoy/cms/templates/scripts/send_usr2.sh +3 -0
- data/lib/generators/enjoy/cms/templates/unicorn.erb +57 -0
- data/lib/generators/enjoy/cms/templates/unicorn.god.erb +59 -0
- data/lib/generators/enjoy/cms/unicorn_god_generator.rb +15 -0
- data/lib/generators/enjoy/{utils.rb → cms/utils.rb} +1 -1
- data/lib/rails_admin/custom_show_in_app.rb +13 -13
- data/template.rb +197 -543
- metadata +73 -325
- data/app/assets/javascripts/enjoy_cms/contacts.coffee +0 -11
- data/app/assets/javascripts/enjoy_cms/rails_admin/cms.ui.coffee +0 -6
- data/app/assets/javascripts/enjoy_cms.coffee +0 -7
- data/app/controllers/concerns/enjoy/blocksetable.rb +0 -37
- data/app/controllers/concerns/enjoy/decorators/contacts.rb +0 -5
- data/app/controllers/concerns/enjoy/decorators/news.rb +0 -5
- data/app/controllers/concerns/enjoy/decorators/pages.rb +0 -5
- data/app/controllers/concerns/enjoy/decorators/search.rb +0 -5
- data/app/controllers/concerns/enjoy/nav_menu.rb +0 -91
- data/app/controllers/concerns/enjoy/seo_pages.rb +0 -90
- data/app/controllers/enjoy/contacts_controller.rb +0 -7
- data/app/controllers/enjoy/news_controller.rb +0 -7
- data/app/controllers/enjoy/pages_controller.rb +0 -7
- data/app/controllers/enjoy/search_controller.rb +0 -8
- data/app/mailers/enjoy/contact_mailer.rb +0 -17
- data/app/models/concerns/enjoy/connectable.rb +0 -36
- data/app/models/concerns/enjoy/decorators/contact_message.rb +0 -5
- data/app/models/concerns/enjoy/decorators/embedded_gallery_image.rb +0 -5
- data/app/models/concerns/enjoy/decorators/gallery.rb +0 -5
- data/app/models/concerns/enjoy/decorators/gallery_image.rb +0 -5
- data/app/models/concerns/enjoy/decorators/menu.rb +0 -5
- data/app/models/concerns/enjoy/decorators/news.rb +0 -5
- data/app/models/concerns/enjoy/decorators/page.rb +0 -5
- data/app/models/concerns/enjoy/decorators/page_block.rb +0 -5
- data/app/models/concerns/enjoy/decorators/page_blockset.rb +0 -5
- data/app/models/concerns/enjoy/decorators/seo.rb +0 -5
- data/app/models/concerns/enjoy/decorators/sitemap_data.rb +0 -5
- data/app/models/concerns/enjoy/mongoid_paperclip.rb +0 -51
- data/app/models/concerns/enjoy/seoable.rb +0 -36
- data/app/models/concerns/enjoy/sitemap_data_field.rb +0 -17
- data/app/models/enjoy/contact_message.rb +0 -16
- data/app/models/enjoy/embedded_gallery_image.rb +0 -16
- data/app/models/enjoy/gallery.rb +0 -13
- data/app/models/enjoy/gallery_image.rb +0 -13
- data/app/models/enjoy/menu.rb +0 -16
- data/app/models/enjoy/news.rb +0 -16
- data/app/models/enjoy/page.rb +0 -16
- data/app/models/enjoy/page_block.rb +0 -13
- data/app/models/enjoy/page_blockset.rb +0 -13
- data/app/models/enjoy/seo.rb +0 -16
- data/app/models/enjoy/sitemap_data.rb +0 -16
- data/app/views/enjoy/contact_mailer/new_message_email.html.slim +0 -15
- data/app/views/enjoy/contacts/_form.html.slim +0 -7
- data/app/views/enjoy/contacts/_form_with_wrapper.html.slim +0 -2
- data/app/views/enjoy/contacts/_success.html.slim +0 -3
- data/app/views/enjoy/contacts/index.html.slim +0 -4
- data/app/views/enjoy/contacts/new.html.slim +0 -4
- data/app/views/enjoy/contacts/sent.html.slim +0 -3
- data/app/views/enjoy/news/index.html.slim +0 -9
- data/app/views/enjoy/news/show.html.slim +0 -8
- data/app/views/enjoy/pages/show.html.slim +0 -1
- data/app/views/enjoy/search/index.html.slim +0 -19
- data/app/views/rails_admin/main/_enjoy_connectable.html.slim +0 -56
- data/config/locales/ru.kaminari.yml +0 -17
- data/config/locales/ru.simple_captcha.yml +0 -3
- data/config/locales/ru.simple_form.yml +0 -9
- data/lib/enjoy/admin/contact_message.rb +0 -42
- data/lib/enjoy/admin/embedded_gallery_image.rb +0 -38
- data/lib/enjoy/admin/gallery.rb +0 -44
- data/lib/enjoy/admin/gallery_image.rb +0 -31
- data/lib/enjoy/admin/menu.rb +0 -27
- data/lib/enjoy/admin/news.rb +0 -89
- data/lib/enjoy/admin/page.rb +0 -96
- data/lib/enjoy/admin/page_block.rb +0 -49
- data/lib/enjoy/admin/page_blockset.rb +0 -50
- data/lib/enjoy/admin/seo.rb +0 -41
- data/lib/enjoy/admin/sitemap_data.rb +0 -29
- data/lib/enjoy/controllers/contacts.rb +0 -86
- data/lib/enjoy/controllers/news.rb +0 -36
- data/lib/enjoy/controllers/pages.rb +0 -22
- data/lib/enjoy/controllers/search.rb +0 -62
- data/lib/enjoy/elastic_search.rb +0 -31
- data/lib/enjoy/models/active_record/contact_message.rb +0 -14
- data/lib/enjoy/models/active_record/menu.rb +0 -17
- data/lib/enjoy/models/active_record/news.rb +0 -26
- data/lib/enjoy/models/active_record/page.rb +0 -20
- data/lib/enjoy/models/active_record/seo.rb +0 -17
- data/lib/enjoy/models/active_record/sitemap_data.rb +0 -11
- data/lib/enjoy/models/contact_message.rb +0 -41
- data/lib/enjoy/models/embedded_gallery_image.rb +0 -13
- data/lib/enjoy/models/gallery.rb +0 -21
- data/lib/enjoy/models/gallery_image.rb +0 -19
- data/lib/enjoy/models/menu.rb +0 -23
- data/lib/enjoy/models/mongoid/contact_message.rb +0 -23
- data/lib/enjoy/models/mongoid/embedded_gallery_image.rb +0 -24
- data/lib/enjoy/models/mongoid/gallery.rb +0 -32
- data/lib/enjoy/models/mongoid/gallery_image.rb +0 -29
- data/lib/enjoy/models/mongoid/menu.rb +0 -20
- data/lib/enjoy/models/mongoid/news.rb +0 -37
- data/lib/enjoy/models/mongoid/page.rb +0 -49
- data/lib/enjoy/models/mongoid/page_block.rb +0 -56
- data/lib/enjoy/models/mongoid/page_blockset.rb +0 -20
- data/lib/enjoy/models/mongoid/seo.rb +0 -35
- data/lib/enjoy/models/mongoid/sitemap_data.rb +0 -25
- data/lib/enjoy/models/news.rb +0 -58
- data/lib/enjoy/models/page.rb +0 -92
- data/lib/enjoy/models/page_block.rb +0 -22
- data/lib/enjoy/models/page_blockset.rb +0 -24
- data/lib/enjoy/models/seo.rb +0 -17
- data/lib/enjoy/models/sitemap_data.rb +0 -17
- data/lib/enjoy/rails_admin_ext/enjoy_connectable.rb +0 -33
- data/lib/enjoy/rails_admin_ext/menu.rb +0 -147
- data/lib/generators/enjoy/capify_generator.rb +0 -39
- data/lib/generators/enjoy/config/templates/enjoy_cms.erb +0 -27
- data/lib/generators/enjoy/migration_generator.rb +0 -18
- data/lib/generators/enjoy/templates/Capfile +0 -17
- data/lib/generators/enjoy/templates/ability.erb +0 -48
- data/lib/generators/enjoy/templates/deploy.erb +0 -47
- data/lib/generators/enjoy/templates/dl.erb +0 -30
- data/lib/generators/enjoy/templates/migration_contact_messages.rb +0 -15
- data/lib/generators/enjoy/templates/migration_news.rb +0 -26
- data/lib/generators/enjoy/templates/migration_pages.rb +0 -45
- data/lib/generators/enjoy/templates/migration_seos.rb +0 -14
- data/lib/generators/enjoy/templates/production.erb +0 -8
- data/lib/generators/enjoy/templates/unicorn.erb +0 -66
@@ -0,0 +1,80 @@
|
|
1
|
+
# Set global optimisation options for all Paperclip models
|
2
|
+
|
3
|
+
# By default, image_optim enables all the compression binaries it supports and
|
4
|
+
# requires them to be present on your system, failing if one is actually missing.
|
5
|
+
|
6
|
+
# We disable everything by default and ignore missing ones with `skip_missing_workers`.
|
7
|
+
# This way, should a new version add support for a library we do not yet disable here,
|
8
|
+
# things won't suddenly break.
|
9
|
+
if defined?(Paperclip::PaperclipOptimizer)
|
10
|
+
Paperclip::PaperclipOptimizer.default_options = {
|
11
|
+
skip_missing_workers: true,
|
12
|
+
advpng: true,
|
13
|
+
gifsicle: true,
|
14
|
+
jhead: true,
|
15
|
+
jpegoptim: true,
|
16
|
+
jpegrecompress: true,
|
17
|
+
jpegtran: true,
|
18
|
+
optipng: true,
|
19
|
+
pngcrush: true,
|
20
|
+
pngout: false,
|
21
|
+
pngquant: true,
|
22
|
+
svgo: false,
|
23
|
+
|
24
|
+
nice: 5,
|
25
|
+
verbose: true
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# All available image_optim options. See https://github.com/toy/image_optim for more information
|
30
|
+
|
31
|
+
# Paperclip::PaperclipOptimizer.default_options = {
|
32
|
+
# skip_missing_workers: false, # Skip workers with missing or problematic binaries (defaults to false)
|
33
|
+
# nice: 10, # Nice level (defaults to 10)
|
34
|
+
# threads: 1, # Number of threads or disable (defaults to number of processors)
|
35
|
+
# verbose: false, # Verbose output (defaults to false)
|
36
|
+
# pack: nil, # Require image_optim_pack or disable it, by default image_optim_pack will be used if available,
|
37
|
+
# # will turn on :skip-missing-workers unless explicitly disabled (defaults to nil)
|
38
|
+
# allow_lossy: false, # Allow lossy workers and optimizations (defaults to false)
|
39
|
+
# advpng: {
|
40
|
+
# leve: 4 # Compression level: 0 - don't compress, 1 - fast, 2 - normal, 3 - extra, 4 - extreme (defaults to 4)
|
41
|
+
# },
|
42
|
+
# gifsicle: {
|
43
|
+
# interlace: true, # Interlace: true - interlace on, false - interlace off, nil - as is in original image
|
44
|
+
# # (defaults to running two instances, one with interlace off and one with on)
|
45
|
+
# level: 3, # Compression level: 1 - light and fast, 2 - normal, 3 - heavy (slower) (defaults to 3)
|
46
|
+
# careful: false # Avoid bugs with some software (defaults to false)
|
47
|
+
# },
|
48
|
+
# jhead: true, # no options
|
49
|
+
# jpegoptim: {
|
50
|
+
# strip: :all, # List of extra markers to strip: :comments, :exif, :iptc, :icc or :all (defaults to :all)
|
51
|
+
# max_quality: 100 # Maximum image quality factor 0..100 (defaults to 100)
|
52
|
+
# },
|
53
|
+
# jpegrecompress: {
|
54
|
+
# quality: 3 # JPEG quality preset: 0 - low, 1 - medium, 2 - high, 3 - veryhigh (defaults to 3)
|
55
|
+
# },
|
56
|
+
# jpegtran: {
|
57
|
+
# copy_chunks: false, # Copy all chunks (defaults to false)
|
58
|
+
# progressive: true, # Create progressive JPEG file (defaults to true)
|
59
|
+
# jpegrescan: false # Use jpegtran through jpegrescan, ignore progressive option (defaults to false)
|
60
|
+
# },
|
61
|
+
# optipng: {
|
62
|
+
# level: 6, # Optimization level preset: 0 is least, 7 is best (defaults to 6)
|
63
|
+
# interlace: false # Interlace: true - interlace on, false - interlace off, nil - as is in original image (defaults to false)
|
64
|
+
# },
|
65
|
+
# pngcrush: {
|
66
|
+
# chunks: :alla, # List of chunks to remove or :alla - all except tRNS/transparency or
|
67
|
+
# # :allb - all except tRNS and gAMA/gamma (defaults to :alla)
|
68
|
+
# fix: false, # Fix otherwise fatal conditions such as bad CRCs (defaults to false)
|
69
|
+
# brute: false # Brute force try all methods, very time-consuming and generally not worthwhile (defaults to false)
|
70
|
+
# },
|
71
|
+
# pngout: {
|
72
|
+
# copy_chunks: false, # Copy optional chunks (defaults to false)
|
73
|
+
# strategy: 0 # Strategy: 0 - xtreme, 1 - intense, 2 - longest Match, 3 - huffman Only, 4 - uncompressed (defaults to 0)
|
74
|
+
# },
|
75
|
+
# pngquant: {
|
76
|
+
# quality: 100..100, # min..max - don't save below min, use less colors below max (both in range 0..100; in yaml - !ruby/range 0..100) (defaults to 100..100)
|
77
|
+
# speed: 3 # speed/quality trade-off: 1 - slow, 3 - default, 11 - fast & rough (defaults to 3)
|
78
|
+
# },
|
79
|
+
# svgo: true # no options
|
80
|
+
# }
|
@@ -0,0 +1,15 @@
|
|
1
|
+
if Rails.env.development?
|
2
|
+
module Rack
|
3
|
+
class CommonLogger
|
4
|
+
alias_method :log_without_assets, :log
|
5
|
+
ASSETS_PREFIX = "/#{Rails.application.config.assets.prefix[/\A\/?(.*?)\/?\z/, 1]}/"
|
6
|
+
def log(env, status, header, began_at)
|
7
|
+
unless env['REQUEST_PATH'].start_with?(ASSETS_PREFIX) || env['REQUEST_PATH'].start_with?('/uploads') || env['REQUEST_PATH'].start_with?('/system')
|
8
|
+
log_without_assets(env, status, header, began_at)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Rack::Utils.multipart_part_limit = 0
|
@@ -0,0 +1,57 @@
|
|
1
|
+
|
2
|
+
rails_root = "/home/#{app_name.downcase}/www/#{app_name.downcase}"
|
3
|
+
|
4
|
+
worker_processes 2
|
5
|
+
working_directory rails_root
|
6
|
+
|
7
|
+
# This loads the application in the master process before forking
|
8
|
+
# worker processes
|
9
|
+
# Read more about it here:
|
10
|
+
# http://unicorn.bogomips.org/Unicorn/Configurator.html
|
11
|
+
preload_app true
|
12
|
+
|
13
|
+
timeout 30
|
14
|
+
|
15
|
+
# This is where we specify the socket.
|
16
|
+
# We will point the upstream Nginx module to this socket later on
|
17
|
+
listen "\#{rails_root}/tmp/sockets/unicorn.sock", :backlog => 64
|
18
|
+
|
19
|
+
pid "\#{rails_root}/tmp/pids/unicorn.pid"
|
20
|
+
|
21
|
+
# Set the path of the log files inside the log folder of the testapp
|
22
|
+
stderr_path "\#{rails_root}/log/unicorn.stderr.log"
|
23
|
+
stdout_path "\#{rails_root}/log/unicorn.stdout.log"
|
24
|
+
|
25
|
+
|
26
|
+
before_fork do |server, worker|
|
27
|
+
server.logger.info("worker=\#{worker.nr} spawning in \#{Dir.pwd}")
|
28
|
+
|
29
|
+
# graceful shutdown.
|
30
|
+
old_pid_file = "\#{rails_root}/tmp/pids/unicorn.pid.oldbin"
|
31
|
+
if File.exists?(old_pid_file) && server.pid != old_pid_file
|
32
|
+
begin
|
33
|
+
old_pid = File.read(old_pid_file).to_i
|
34
|
+
server.logger.info("sending QUIT to \#{old_pid}")
|
35
|
+
# we're killing old unicorn master right there
|
36
|
+
Process.kill("QUIT", old_pid)
|
37
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
38
|
+
# someone else did our job for us
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
## no need for noSQL
|
44
|
+
# before_fork do |server, worker|
|
45
|
+
# # This option works in together with preload_app true setting
|
46
|
+
# # What is does is prevent the master process from holding
|
47
|
+
# # the database connection
|
48
|
+
# defined?(ActiveRecord::Base) and
|
49
|
+
# ActiveRecord::Base.connection.disconnect!
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# after_fork do |server, worker|
|
53
|
+
# # Here we are establishing the connection after forking worker
|
54
|
+
# # processes
|
55
|
+
# defined?(ActiveRecord::Base) and
|
56
|
+
# ActiveRecord::Base.establish_connection
|
57
|
+
# end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# http://unicorn.bogomips.org/SIGNALS.html
|
2
|
+
|
3
|
+
rails_env = ENV['RAILS_ENV'] || 'production'
|
4
|
+
rails_root = ENV['RAILS_ROOT'] || File.dirname(File.dirname(__FILE__))
|
5
|
+
|
6
|
+
God.watch do |w|
|
7
|
+
w.name = "unicorn_#{app_name.downcase}"
|
8
|
+
w.interval = 30.seconds # default
|
9
|
+
|
10
|
+
# unicorn needs to be run from the rails root
|
11
|
+
w.start = "cd \#{rails_root} && unicorn -c \#{rails_root}/config/unicorn.rb -E \#{rails_env} -D"
|
12
|
+
|
13
|
+
# QUIT gracefully shuts down workers
|
14
|
+
w.stop = "kill -KILL `cat \#{rails_root}/tmp/pids/unicorn.pid`"
|
15
|
+
|
16
|
+
# USR2 causes the master to re-create itself and spawn a new worker pool
|
17
|
+
w.restart = "kill -USR2 `cat \#{rails_root}/tmp/pids/unicorn.pid`"# && cd \#{rails_root} && unicorn -c \#{rails_root}/config/unicorn.rb -E \#{rails_env} -D"
|
18
|
+
|
19
|
+
w.start_grace = 10.seconds
|
20
|
+
w.restart_grace = 10.seconds
|
21
|
+
w.pid_file = "\#{rails_root}/tmp/pids/unicorn.pid"
|
22
|
+
|
23
|
+
w.uid = '#{app_name.downcase}'
|
24
|
+
w.gid = '#{app_name.downcase}'
|
25
|
+
|
26
|
+
w.behavior(:clean_pid_file)
|
27
|
+
|
28
|
+
w.start_if do |start|
|
29
|
+
start.condition(:process_running) do |c|
|
30
|
+
c.interval = 5.seconds
|
31
|
+
c.running = false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
w.restart_if do |restart|
|
36
|
+
restart.condition(:memory_usage) do |c|
|
37
|
+
c.above = 150.megabytes
|
38
|
+
c.times = [3, 5] # 3 out of 5 intervals
|
39
|
+
end
|
40
|
+
|
41
|
+
restart.condition(:cpu_usage) do |c|
|
42
|
+
c.above = 50.percent
|
43
|
+
c.times = 5
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# lifecycle
|
48
|
+
w.lifecycle do |on|
|
49
|
+
on.condition(:flapping) do |c|
|
50
|
+
c.to_state = [:start, :restart]
|
51
|
+
c.times = 5
|
52
|
+
c.within = 5.minute
|
53
|
+
c.transition = :unmonitored
|
54
|
+
c.retry_in = 10.minutes
|
55
|
+
c.retry_times = 5
|
56
|
+
c.retry_within = 2.hours
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Enjoy::Cms
|
4
|
+
class UnicornGodGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
argument :app_name, type: :string
|
8
|
+
|
9
|
+
desc 'Enjoy CMS unicorn+god configs generator'
|
10
|
+
def install
|
11
|
+
template 'unicorn.erb', "config/unicorn.rb"
|
12
|
+
template 'unicorn.god.erb', "config/unicorn.god"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -14,19 +14,19 @@ module RailsAdmin
|
|
14
14
|
|
15
15
|
register_instance_option :controller do
|
16
16
|
Proc.new do
|
17
|
-
if @object.class.name == 'Enjoy::Page'
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
elsif @object.class.name == 'Enjoy::News'
|
24
|
-
|
25
|
-
elsif @object.class.name == 'Obj'
|
26
|
-
|
27
|
-
else
|
28
|
-
|
29
|
-
end
|
17
|
+
# if @object.class.name == 'Enjoy::Page'
|
18
|
+
# if @object.fullpath.blank?
|
19
|
+
# redirect_to main_app.page_url(@object)
|
20
|
+
# else
|
21
|
+
# redirect_to @object.fullpath
|
22
|
+
# end
|
23
|
+
# elsif @object.class.name == 'Enjoy::News'
|
24
|
+
# redirect_to main_app.news_url(@object)
|
25
|
+
# elsif @object.class.name == 'Obj'
|
26
|
+
# redirect_to main_app.object_url(@object.category, @object)
|
27
|
+
# else
|
28
|
+
# redirect_to main_app.url_for(@object)
|
29
|
+
# end
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|