From 2612e429af202633bc1472a46157d8803bf7037c Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 26 Dec 2017 14:06:27 +0100 Subject: Mount Refinery under suburl if specified in environment. This is to make sure all generated url's within the application uses the correct base URL. --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/routes.rb b/config/routes.rb index 2eb025f..0c10b0d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,7 +5,7 @@ BetaWebApp::Application.routes.draw do # If you would like to change where this extension is mounted, simply change the :at option to something different. # # We ask that you don't use the :as option here, as Refinery relies on it being the default of "refinery" - mount Refinery::Core::Engine, :at => '/' + mount Refinery::Core::Engine, at: ENV['RAILS_RELATIVE_URL_ROOT'] || '/' # The priority is based upon order of creation: # first created -> highest priority. -- cgit v1.2.3 From 42e4eaa01504dadd3ff37fce49119ae3f156b23e Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 26 Dec 2017 19:45:43 +0100 Subject: Capistrano task for uploading puma config. --- config/deploy/templates/puma.rb.erb | 121 ++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 config/deploy/templates/puma.rb.erb (limited to 'config') diff --git a/config/deploy/templates/puma.rb.erb b/config/deploy/templates/puma.rb.erb new file mode 100644 index 0000000..abc68cc --- /dev/null +++ b/config/deploy/templates/puma.rb.erb @@ -0,0 +1,121 @@ +#!/usr/bin/env puma + +# Original from: +# https://gist.githubusercontent.com/thanhhh/5610668/raw/fdfe2a865c3a0afe912c8784c971ea7ca3e64cfd/puma.rb +# Modified for heavymetal.no by Harald Eilertsen + +# Start Puma with next command: +# RAILS_ENV=production bundle exec puma -C ./config/puma.rb + +# uncomment and customize to run in non-root path +# ENV['RAILS_RELATIVE_URL_ROOT'] = "/suburl" + +application_path = '<%= fetch(:deploy_to) %>' + +# The directory to operate out of. +# +# Make it pick up the current path from capistrano deploy. +# +directory File.join(application_path, 'current') + +# Set the environment in which the rack's app will run. +# +# Pick it up from the app environment. +# +environment ENV['RACK_ENV'] + +# Daemonize the server into the background. Highly suggest that +# this be combined with “pidfile” and “stdout_redirect”. +# +# The default is “false”. +# +daemonize true + +# Store the pid of the server in the file at “path”. +# +pidfile "#{application_path}/shared/tmp/pids/puma.pid" + +# Use “path” as the file to store the server info state. This is +# used by “pumactl” to query and control the server. +# +state_path "#{application_path}/shared/tmp/pids/puma.state" + +# Redirect STDOUT and STDERR to files specified. The 3rd parameter +# (“append”) specifies whether the output is appended, the default is +# “false”. +# +stdout_redirect "#{application_path}/shared/log/puma.stdout.log", + "#{application_path}/shared/log/puma.stderr.log" + +# Disable request logging. +# +# The default is “false”. +# +# quiet + +# Configure “min” to be the minimum number of threads to use to answer +# requests and “max” the maximum. +# +# The default is “0, 16”. +# +# threads 0, 16 + +# Bind the server to “url”. “tcp://”, “unix://” and “ssl://” are the only +# accepted protocols. +# +# The default is “tcp://0.0.0.0:9292”. +# +# bind 'tcp://0.0.0.0:9292' +bind "unix://#{application_path}/shared/tmp/sockets/puma.sock" + +# Instead of “bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'” you +# can also use the “ssl_bind” option. +# +# ssl_bind '127.0.0.1', '9292', { key: path_to_key, cert: path_to_cert } + +# Code to run before doing a restart. This code should +# close log files, database connections, etc. +# +# This can be called multiple times to add code each time. +# +# on_restart do +# puts 'On restart...' +# end + +# Command to use to restart puma. This should be just how to +# load puma itself (ie. 'ruby -Ilib bin/puma'), not the arguments +# to puma, as those are the same as the original process. +# +# restart_command '/u/app/lolcat/bin/restart_puma' + +# === Cluster mode === + +# How many worker processes to run. +# +# The default is “0”. +# +# workers 2 + +# Code to run when a worker boots to setup the process before booting +# the app. +# +# This can be called multiple times to add hooks. +# +# on_worker_boot do +# puts 'On worker boot...' +# end + +# === Puma control rack application === + +# Start the puma control rack application on “url”. This application can +# be communicated with to control the main server. Additionally, you can +# provide an authentication token, so all requests to the control server +# will need to include that token as a query parameter. This allows for +# simple authentication. +# +# Check out https://github.com/puma/puma/blob/master/lib/puma/app/status.rb +# to see what the app has available. +# +# activate_control_app 'unix:///var/run/pumactl.sock' +# activate_control_app 'unix:///var/run/pumactl.sock', { auth_token: '12345' } +# activate_control_app 'unix:///var/run/pumactl.sock', { no_token: true } -- cgit v1.2.3 From ab9be5dd966c65f290660682d60e9f27eaaca0e4 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 26 Dec 2017 19:52:49 +0100 Subject: Add configs for stagingtest and prodtest environments. --- config/environments/prodtest.rb | 69 ++++++++++++++++++++++++++++++++++++++ config/environments/stagingtest.rb | 67 ++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 config/environments/prodtest.rb create mode 100644 config/environments/stagingtest.rb (limited to 'config') diff --git a/config/environments/prodtest.rb b/config/environments/prodtest.rb new file mode 100644 index 0000000..e39ab27 --- /dev/null +++ b/config/environments/prodtest.rb @@ -0,0 +1,69 @@ +require 'syslog/logger' + +BetaWebApp::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # Code is not reloaded between requests + config.cache_classes = true + + # Full error reports are disabled and caching is turned on + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Disable Rails's static asset server (Apache or nginx will already do this) + config.serve_static_assets = false + + # Compress JavaScripts and CSS + config.assets.compress = true + + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = true + + # Generate digests for assets URLs + config.assets.digest = true + + # Defaults to nil and saved in location specified by config.assets.prefix + # config.assets.manifest = YOUR_PATH + + # Specifies the header that your server uses for sending files + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # See everything in the log (default is :info) + # config.log_level = :debug + + # Prepend all log lines with the following tags + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups + config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new('hmno')) + + # Use a different cache store in production + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + + # Disable delivery errors, bad email addresses will be ignored + # config.action_mailer.raise_delivery_errors = false + + # Enable threaded mode + # config.threadsafe! + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found) + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners + config.active_support.deprecation = :notify + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + # config.active_record.auto_explain_threshold_in_seconds = 0.5 +end diff --git a/config/environments/stagingtest.rb b/config/environments/stagingtest.rb new file mode 100644 index 0000000..65c0e3c --- /dev/null +++ b/config/environments/stagingtest.rb @@ -0,0 +1,67 @@ +BetaWebApp::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # Code is not reloaded between requests + config.cache_classes = true + + # Full error reports are disabled and caching is turned on + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Disable Rails's static asset server (Apache or nginx will already do this) + config.serve_static_assets = false + + # Compress JavaScripts and CSS + config.assets.compress = true + + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = true + + # Generate digests for assets URLs + config.assets.digest = true + + # Defaults to nil and saved in location specified by config.assets.prefix + # config.assets.manifest = YOUR_PATH + + # Specifies the header that your server uses for sending files + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # See everything in the log (default is :info) + # config.log_level = :debug + + # Prepend all log lines with the following tags + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + + # Disable delivery errors, bad email addresses will be ignored + # config.action_mailer.raise_delivery_errors = false + + # Enable threaded mode + # config.threadsafe! + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found) + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners + config.active_support.deprecation = :notify + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + # config.active_record.auto_explain_threshold_in_seconds = 0.5 +end -- cgit v1.2.3 From 9c22d9e8978b836da2fdaa3bd3d05fcff0124b91 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 6 Jan 2018 15:49:08 +0100 Subject: Set prefix for assets in prodtest. --- config/environments/prodtest.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'config') diff --git a/config/environments/prodtest.rb b/config/environments/prodtest.rb index e39ab27..0bcf9e2 100644 --- a/config/environments/prodtest.rb +++ b/config/environments/prodtest.rb @@ -25,6 +25,8 @@ BetaWebApp::Application.configure do # Defaults to nil and saved in location specified by config.assets.prefix # config.assets.manifest = YOUR_PATH + config.assets.prefix = '/beta/assets' + # Specifies the header that your server uses for sending files # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx -- cgit v1.2.3 From b93d0bf68c25d266c6106e09bafbfd565296b76a Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 6 Jan 2018 18:12:37 +0100 Subject: Allways pick up relative url for asset prefix. --- config/application.rb | 2 ++ config/environments/prodtest.rb | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/application.rb b/config/application.rb index 7006797..d3de916 100644 --- a/config/application.rb +++ b/config/application.rb @@ -64,5 +64,7 @@ module BetaWebApp # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' + + config.assets.prefix = "#{ENV['RAILS_RELATIVE_URL_ROOT']}/asserts" end end diff --git a/config/environments/prodtest.rb b/config/environments/prodtest.rb index 0bcf9e2..e39ab27 100644 --- a/config/environments/prodtest.rb +++ b/config/environments/prodtest.rb @@ -25,8 +25,6 @@ BetaWebApp::Application.configure do # Defaults to nil and saved in location specified by config.assets.prefix # config.assets.manifest = YOUR_PATH - config.assets.prefix = '/beta/assets' - # Specifies the header that your server uses for sending files # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx -- cgit v1.2.3 From c832ed49cc39f009e3db5df8e8e40d19a6b62643 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 6 Jan 2018 18:46:14 +0100 Subject: Typo 'asserts' => 'assets', old habits die hard. --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config') diff --git a/config/application.rb b/config/application.rb index d3de916..dbefb32 100644 --- a/config/application.rb +++ b/config/application.rb @@ -65,6 +65,6 @@ module BetaWebApp # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' - config.assets.prefix = "#{ENV['RAILS_RELATIVE_URL_ROOT']}/asserts" + config.assets.prefix = "#{ENV['RAILS_RELATIVE_URL_ROOT']}/assets" end end -- cgit v1.2.3