Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Puma web server #9329

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .teatro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ stage:
- cp config/gitlab.teatro.yml config/gitlab.yml
- mkdir /apps/gitlab-satellites
- mkdir /apps/repositories

database:
- RAILS_ENV=development force=yes bundle exec rake db:create gitlab:setup
- RAILS_ENV=development force=yes bundle exec rake db:create gitlab:setup
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ group :unicorn do
gem "unicorn", '~> 4.6.3'
gem 'unicorn-worker-killer'
end
group :puma do
gem 'puma'
gem 'puma_worker_killer'
end

# State machine
gem "state_machine"
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ GEM
rugged (~> 0.21)
gemojione (2.0.0)
json
get_process_mem (0.2.0)
gherkin-ruby (0.3.1)
racc
github-markup (1.3.1)
Expand Down Expand Up @@ -414,6 +415,11 @@ GEM
slop (~> 3.4)
pry-rails (0.3.2)
pry (>= 0.9.10)
puma (2.11.3)
rack (>= 1.1, < 2.0)
puma_worker_killer (0.0.3)
get_process_mem (~> 0.1)
puma (~> 2.7)
pyu-ruby-sasl (0.0.3.3)
quiet_assets (1.0.2)
railties (>= 3.1, < 5.0)
Expand Down Expand Up @@ -763,6 +769,8 @@ DEPENDENCIES
pg
poltergeist (~> 1.5.1)
pry-rails
puma
puma_worker_killer
quiet_assets (~> 1.0.1)
rack-attack (~> 4.3.0)
rack-cors
Expand Down
14 changes: 14 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ if defined?(Unicorn)
use Unicorn::WorkerKiller::Oom, (200 * (1 << 20)), (250 * (1 << 20))
end

if defined?(Puma)
require 'puma'
# Puma self-process killer
require 'puma_worker_killer'

# Max memory size (RSS) per worker
PumaWorkerKiller.config do |config|
config.ram = 250 # mb
config.frequency = 20 # seconds
config.percent_usage = 0.98
end
PumaWorkerKiller.start
end

require ::File.expand_path('../config/environment', __FILE__)

map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do
Expand Down
98 changes: 98 additions & 0 deletions config/puma.rb.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/env puma

# Start Puma with next command:
# RAILS_ENV=production bundle exec puma -C ./config/puma.rb

# uncomment and customize to run in non-root path
# note that config/gitlab.yml web path should also be changed
# ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab"

application_path = '/home/git/gitlab'
directory application_path
environment 'production'
daemonize true
pidfile "#{application_path}/tmp/pids/puma.pid"
state_path "#{application_path}/tmp/pids/puma.state"
stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"

# 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
threads 0, 4

# 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=0777'
# bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
#
## Comment the next line if you use apache.
bind "unix://#{application_path}/tmp/sockets/gitlab.socket"

# 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
workers 0

# GitLab cluster mode recommendations
# If you have more than 1 GB RAM, uncomment one of the following lines:
#
# workers 2 # if you have at least 1.5 GB RAM
# workers 3 # if you have at least 2 GB RAM
# workers 4 # if you have at least 2.5 GB RAM

# 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 }
4 changes: 2 additions & 2 deletions doc_styleguide.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Documentation styleguide

This styleguide recommends best practices to improve documentation and to keep it organized and easy to find.
This styleguide recommends best practices to improve documentation and to keep it organized and easy to find.

## Text

Expand All @@ -19,4 +19,4 @@ This styleguide recommends best practices to improve documentation and to keep i

* Images should have a specific, non-generic name that will differentiate them.

* Keep all file names in lower case.
* Keep all file names in lower case.