summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-09-12 17:22:12 +0200
committerHarald Eilertsen <haraldei@anduin.net>2018-09-12 17:22:12 +0200
commitb7526da833dd14e1f1d95bf7726c2651ff71c818 (patch)
treed71b1136f536086442dc8e6813dd3db0826a7400
parentd0ff91a30233231dc5de5efd0d05f51bdff92a71 (diff)
downloadnorsk-urskog-registrations-b7526da833dd14e1f1d95bf7726c2651ff71c818.tar.gz
norsk-urskog-registrations-b7526da833dd14e1f1d95bf7726c2651ff71c818.tar.bz2
norsk-urskog-registrations-b7526da833dd14e1f1d95bf7726c2651ff71c818.zip
Serve app with puma instead of thin.
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock5
-rw-r--r--config/puma.rb129
3 files changed, 24 insertions, 112 deletions
diff --git a/Gemfile b/Gemfile
index b1683b6..e1f873c 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,7 +6,7 @@ gem "sinatra-config-file"
gem "asciidoctor"
gem "mail"
gem "prawn"
-gem "thin"
+gem "puma"
group :development, :test do
gem 'byebug'
diff --git a/Gemfile.lock b/Gemfile.lock
index bc18ac0..f599a4d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -66,6 +66,7 @@ GEM
prawn (2.1.0)
pdf-core (~> 0.6.1)
ttfunk (~> 1.4.0)
+ puma (3.12.0)
rack (1.6.4)
rack-protection (1.5.3)
rack
@@ -140,6 +141,7 @@ DEPENDENCIES
mail
mailcatcher
prawn
+ puma
rack-test
rspec
rspec-html-matchers
@@ -147,7 +149,6 @@ DEPENDENCIES
sinatra
sinatra-config-file
sinatra-url-for
- thin
BUNDLED WITH
- 1.14.6
+ 1.16.1
diff --git a/config/puma.rb b/config/puma.rb
index ae0cb1c..62073b5 100644
--- a/config/puma.rb
+++ b/config/puma.rb
@@ -1,122 +1,33 @@
#!/usr/bin/env puma
-# Original from:
-# https://gist.githubusercontent.com/thanhhh/5610668/raw/fdfe2a865c3a0afe912c8784c971ea7ca3e64cfd/puma.rb
-# Modified for norsk-urskog.no by Harald Eilertsen <haraldei@anduin.net>
+if get(:environment) == "production"
+ root = "../../shared"
+else
+ root = "."
+end
-# 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'] = "/registration"
-
-application_path = '/home/norskurskog/www/registration'
-
-# 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['RAILS_ENV']
-
-# Daemonize the server into the background. Highly suggest that
-# this be combined with "pidfile" and "stdout_redirect".
+# Store the pid of the server in the file at “path”.
#
-# 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"
+pidfile "#{root}/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.
+# 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"
+state_path "#{root}/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".
+# (“append”) specifies whether the output is appended, the default is
+# “false”.
#
-# threads 0, 16
+stdout_redirect "#{root}/log/puma.stdout.log",
+ "#{root}/log/puma.stderr.log"
-# 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'
+if get(:environment) == "production"
+ bind "unix://../../shared/tmp/sockets/puma.sock"
+else
+ bind "tcp://localhost:3000"
+end
# === 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 }
+workers 4