This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssl_context = ssl.create_default_context(cafile="config/keys/cacert.pem") | |
ssl_context.load_cert_chain(certfile="config/keys/cert.pem", keyfile="config/keys/key.pem") | |
ssl_options = pika.SSLOptions(ssl_context) | |
conn_options = pika.ConnectionParameters( | |
host="mq", | |
ssl_options=ssl_options, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
connection = Buuny.new( | |
host: "mq", | |
tls: true, | |
tls_cert: 'config/keys/cert.pem', | |
tls_key: 'config/keys/key.pem', | |
tls_ca_certificates: ['config/keys/cacert.pem'] | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func NewTLSConfig(host string, cacert, cert, key []byte) (*tls.Config, error) { | |
tlsConfig := tls.Config{ServerName: host} | |
tlsConfig.RootCAs = x509.NewCertPool() | |
tlsConfig.RootCAs.AppendCertsFromPEM(cacert) | |
keyPair, err := tls.X509KeyPair( | |
cert, | |
key, | |
) | |
if err != nil { | |
return nil, err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func NewTLSConfig(host string, cacert, cert, key []byte) (*tls.Config, error) { | |
tlsConfig := tls.Config{ServerName: host} | |
tlsConfig.RootCAs = x509.NewCertPool() | |
tlsConfig.RootCAs.AppendCertsFromPEM(cacert) | |
keyPair, err := tls.X509KeyPair( | |
cert, | |
key, | |
) | |
if err != nil { | |
return nil, err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def wait_for_termination(timeout = 0) | |
Timeouter.run(timeout) do |t| | |
@threads.all? do |thread| | |
thread.join(t.left) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.describe 'Proconsul' do | |
let(:port) { 8500 } | |
let(:consul) { "exec consul agent -ui -server -bind 127.0.0.1 -client 127.0.0.1 -http-port #{port} -dev > /dev/null" } | |
# Проверяем что consul слушает на порту | |
def check_http(uri, timeout: 2) | |
started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
while (Process.clock_gettime(Process::CLOCK_MONOTONIC) - started_at) <= 2 | |
c = Net::HTTP.start(uri.host, uri.port, read_timeout: 1, open_timeout: 1) rescue nil | |
return true if c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'CLI' do | |
let(:proconsul) { File.join($root, '../', 'bin', 'proconsul') } | |
let(:proconsul_copnsul) { "#{proconsul} --consul=http://localhost:#{port}" } | |
let(:read_kv) { flatten_map(Diplomat::Kv.get('/', recurse: true, convert_to_hash: true, nil_values: true)) } | |
it 'wait for consul service healthy through --depend option' do | |
system("#{proconsul_copnsul} exec --depend consul -- echo ok > /dev/null") | |
expect($CHILD_STATUS.success?).to be_truthy | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Middleware | |
def initialize(app, limiter_klass:, killer: **opts) | |
@app = app | |
@killer = killer | |
@limiter = limiter_klass.new(opts) | |
end | |
def call(env) | |
return @app.call(env) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'get_process_mem' | |
class MemoryLimiter | |
attr_reader :min, :max, :limit, :check_cycle | |
attr_accessor :reaction | |
def initialize(min: (1024**3), max: (2 * (1024**3)), check_cycle: 16, &block) | |
@min = min | |
@max = max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PassengerKiller | |
def initialize **kwrags | |
@cmd = "passenger-config detach-process" | |
end | |
def kill() | |
return if @already_detached | |
cmd = "#{@cmd} #{Process.pid}" |
OlderNewer