Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2015-11-25 13:32:18 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2016-06-10 16:46:58 +0300
commit85a7eff5841c866576bdf34248266465baa0fc9f (patch)
treefedf1afc9f1511c7b3e77bf02206eca20aed6785
parentf29fd65cdde1d769fc89f0cc57ea989765b5068f (diff)
Add experimental support for Pumapuma
This allows us (and others) to test drive Puma without it affecting all users. Puma can be enabled by setting the environment variable "USE_PUMA" to a non empty value.
-rw-r--r--Gemfile5
-rw-r--r--Gemfile.lock6
-rw-r--r--config/initializers/puma.rb22
-rw-r--r--config/puma.rb.example171
4 files changed, 204 insertions, 0 deletions
diff --git a/Gemfile b/Gemfile
index b2660144f2b..60ec6b14849 100644
--- a/Gemfile
+++ b/Gemfile
@@ -127,6 +127,11 @@ group :unicorn do
gem 'unicorn-worker-killer', '~> 0.4.2'
end
+group :puma do
+ gem 'puma', '~> 2.15', require: false
+ gem 'puma_worker_killer', require: false
+end
+
# State machine
gem "state_machines-activerecord", '~> 0.4.0'
# Run events after state machine commits
diff --git a/Gemfile.lock b/Gemfile.lock
index dfc15700494..afd91aabe3a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -515,6 +515,10 @@ GEM
slop (~> 3.4)
pry-rails (0.3.4)
pry (>= 0.9.10)
+ puma (2.15.3)
+ puma_worker_killer (0.0.4)
+ get_process_mem (~> 0.2)
+ puma (~> 2.7)
pyu-ruby-sasl (0.0.3.3)
quiet_assets (1.0.3)
railties (>= 3.1, < 5.0)
@@ -945,6 +949,8 @@ DEPENDENCIES
poltergeist (~> 1.9.0)
premailer-rails (~> 1.9.0)
pry-rails
+ puma (~> 2.15)
+ puma_worker_killer
quiet_assets (~> 1.0.2)
rack-attack (~> 4.3.1)
rack-cors (~> 0.4.0)
diff --git a/config/initializers/puma.rb b/config/initializers/puma.rb
new file mode 100644
index 00000000000..f737f07f1fe
--- /dev/null
+++ b/config/initializers/puma.rb
@@ -0,0 +1,22 @@
+if ENV['USE_PUMA']
+ require 'puma'
+ require 'puma_worker_killer'
+
+ if Rails.env.production? or Rails.env.staging?
+ PumaWorkerKiller.config do |config|
+ config.ram = 250
+ config.frequency = 5
+
+ # We just wan't to limit to a fixed maximum, unrelated to the total amount
+ # of available RAM.
+ config.percent_usage = 100.0
+
+ # Ideally we'll never hit the maximum amount of memory. If so the worker
+ # is restarted already, thus periodically restarting workers shouldn't be
+ # needed.
+ config.rolling_restart_frequency = false
+ end
+
+ PumaWorkerKiller.start
+ end
+end
diff --git a/config/puma.rb.example b/config/puma.rb.example
new file mode 100644
index 00000000000..b499348cd1c
--- /dev/null
+++ b/config/puma.rb.example
@@ -0,0 +1,171 @@
+# The directory to operate out of.
+#
+# The default is the current directory.
+#
+directory '/home/git/gitlab'
+
+# Load "path" as a rackup file.
+#
+# The default is "config.ru".
+#
+rackup 'config.ru'
+
+# Daemonize the server into the background. Highly suggest that
+# this be combined with "pidfile" and "stdout_redirect".
+#
+# The default is "false".
+#
+# daemonize
+# daemonize false
+
+# Store the pid of the server in the file at "path".
+#
+pidfile '/home/git/gitlab/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 '/home/git/gitlab/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 '/home/git/gitlab/log/puma.stdout.log',
+ '/home/git/gitlab/log/puma.stderr.log',
+ true
+
+# 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 32, 64
+
+# 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:///var/run/puma.sock'
+# bind 'unix:///var/run/puma.sock?umask=0111'
+# bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
+bind 'unix:///home/git/gitlab/tmp/sockets/gitlab.socket'
+bind 'tcp://127.0.0.1:8080'
+
+# 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
+
+on_restart do
+ ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord::Base)
+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 3
+
+# 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
+
+on_worker_boot do
+ ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base)
+end
+
+# Code to run when a worker boots to setup the process after booting
+# the app.
+#
+# This can be called multiple times to add hooks.
+#
+# after_worker_boot do
+# puts 'After worker boot...'
+# end
+
+# Code to run when a worker shutdown.
+#
+#
+# on_worker_shutdown do
+# puts 'On worker shutdown...'
+# end
+
+# Allow workers to reload bundler context when master process is issued
+# a USR1 signal. This allows proper reloading of gems while the master
+# is preserved across a phased-restart. (incompatible with preload_app)
+# (off by default)
+
+# prune_bundler
+
+# Preload the application before starting the workers; this conflicts with
+# phased restart feature. (off by default)
+
+preload_app!
+
+# Additional text to display in process listing
+#
+tag 'GitLab Puma'
+
+#
+# If you do not specify a tag, Puma will infer it. If you do not want Puma
+# to add a tag, use an empty string.
+
+# Verifies that all workers have checked in to the master process within
+# the given timeout. If not the worker process will be restarted. Default
+# value is 60 seconds.
+#
+worker_timeout 60
+
+# Change the default worker timeout for booting
+#
+# If unspecified, this defaults to the value of worker_timeout.
+#
+# worker_boot_timeout 60
+
+# === 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 }
+#
+# vim: set ft=ruby: