Merge pull request #348 from phracek/support_github_matrix

Support GitHub matrix
This commit is contained in:
phracek 2021-11-23 13:19:17 +00:00
commit 05c36dd1ce
36 changed files with 3872 additions and 0 deletions

9
root/opt/app-root/.gemrc Normal file
View file

@ -0,0 +1,9 @@
---
install: --no-document
update: --no-document
:benchmark: false
:update_sources: true
:bulk_threshold: 1000
:backtrace: true
:sources:
- https://rubygems.org/

View file

@ -0,0 +1,50 @@
def get_max_memory()
return ENV['MEMORY_LIMIT_IN_BYTES'].to_i if ENV.has_key? 'MEMORY_LIMIT_IN_BYTES'
# Assume unlimited memory. 0.size is the number of bytes a Ruby
# Fixnum class can hold. One bit is used for sign and one is used
# by Ruby to determine whether it's a number or pointer to an object.
# That's why we subtract two bits. This expresion should therefore be
# the largest signed Fixnum possible.
(2 ** (8*0.size - 2) - 1)
end
def get_memory_per_worker()
bytes = ENV.fetch('MEMORY_BYTES_PER_WORKER', '0').to_i
if bytes == 0
# Comment describing rationale for choosing default of 256MiB/worker is below.
bytes = 256 * (2**20)
end
bytes
end
def get_min_threads()
ENV.fetch('PUMA_MIN_THREADS', '0').to_i
end
def get_max_threads()
ENV.fetch('PUMA_MAX_THREADS', '16').to_i
end
# Determine the maximum number of workers that are allowed by the available
# memory. Puma documentation recommends the maximum number of workers to be
# set to the number of cores.
# Unless we're specifically tuned otherwise, allow one worker process per 256MiB
# memory, to a maximum of 1 worker / core. Hopefully that'll be a reasonable
# starting point for average apps; if not, it's all tunable. The simple
# OpenShift ruby/rails sample app currently requires approx. 60MiB +
# 70MiB/worker before taking its first request, so hopefully a default of
# 256MiB/worker will give other simple apps reasonable default headroom.
def get_workers()
return ENV['PUMA_WORKERS'].to_i if ENV.has_key? 'PUMA_WORKERS'
cores = ENV.fetch('NUMBER_OF_CORES', '1').to_i
max_workers = get_max_memory() / get_memory_per_worker()
[cores, max_workers].min
end
environment ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'production'
threads get_min_threads(), get_max_threads()
workers get_workers()
bind 'tcp://0.0.0.0:8080'

View file

@ -0,0 +1,6 @@
# IMPORTANT: Do not add more content to this file unless you know what you are
# doing. This file is sourced everytime the shell session is opened.
#
# This will make scl collection binaries work out of box.
unset BASH_ENV PROMPT_COMMAND ENV
source scl_source enable $NODEJS_SCL rh-ruby27