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
# Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed. | |
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies. | |
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module | |
# | |
# Deployment structure | |
# | |
# SERVER: | |
# /etc/init.d/nginx (1. nginx) | |
# /home/app/public_html/app_production/current (Capistrano directory) | |
# |
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
events { | |
worker_connections 1024; | |
} | |
http { | |
default_type text/html; | |
access_log /dev/stdout; | |
sendfile on; | |
keepalive_timeout 65; |
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
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776 | |
$ cd /usr/src | |
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz | |
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz | |
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz | |
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz | |
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz |
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
# Nginx can serve FLV/MP4 files by pseudo-streaming way without any specific media-server software. | |
# To do the custom build we use 2 modules: --with-http_secure_link_module --with-http_flv_module | |
# This module "secure-link" helps you to protect links from stealing away. | |
# | |
# NOTE: see more details at coderwall: http://coderwall.com/p/3hksyg | |
cd /usr/src | |
wget http://nginx.org/download/nginx-1.5.13.tar.gz | |
tar xzvf ./nginx-1.5.13.tar.gz && rm -f ./nginx-1.5.13.tar.gz |
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
log_format json '{' | |
'"http":{' | |
'"method":"$request_method",' | |
'"request_id":"$request_id",' | |
'"status_code":$status,' | |
'"content_type":"$content_type",' | |
'"url":"$request_uri",' | |
'"url_details":{' | |
'"path":"$uri",' | |
'"scheme":"$scheme",' |
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
upstream upstream_close_server_keepalive_timeout_0 { | |
server upstream:10443; | |
} | |
upstream upstream_keepalive_server_keepalive_timeout_0 { | |
server upstream:11443; | |
keepalive 64; | |
} | |
upstream upstream_close_server_keepalive_timeout_300 { |
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
- http://www.coffeepowered.net/2009/06/13/fine-tuning-your-garbage-collector/ | |
- http://snaprails.tumblr.com/post/241746095/rubys-gc-configuration | |
article’s settings: ("spec spec" took 17-23!sec) | |
export RUBY_HEAP_MIN_SLOTS=1250000 | |
export RUBY_HEAP_SLOTS_INCREMENT=100000 | |
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 | |
export RUBY_GC_MALLOC_LIMIT=30000000 | |
export RUBY_HEAP_FREE_MIN=12500 |
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
#!/bin/bash -e | |
curl -O http://ftp.heanet.ie/pub/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso | |
export VM="MASTER" | |
export VMDISK="$VM-disk" | |
export REDHAT_IMAGE="/Users/user/Downloads/CentOS-7.0-1406-x86_64-Minimal.iso" | |
VBoxManage hostonlyif create | |
VBoxManage hostonlyif ipconfig vboxnet0 --ip 192.168.20.1 |
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
#!/bin/bash | |
set -ex | |
# Inject APM Trace ID (part of SQL query comment) to a Log event | |
# https://docs.datadoghq.com/tracing/advanced/connect_logs_and_traces/?tab=ruby | |
# Input: {"command": "Query", "current_statement": "SELECT ... /* 4572859165692197980 */"} | |
# Output: {"process_list": {"current_statement": "SELECT ... /* 4572859165692197980 */"}, "dd": {"trace_id": 4572859165692197980}} | |
function inject_trace_id() { | |
trace_id=$(echo "$1" |grep -Eo '/\* [0-9]{16,20} \*/' | awk '{print $2}') |
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
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args| | |
event = ActiveSupport::Notifications::Event.new(*args) | |
span = Datadog.tracer.active_span | |
payload = event.payload | |
if span && payload.key?(:db_runtime) | |
db_runtime = payload[:db_runtime].to_f.round(3) | |
span.set_tag('database.sql_time', db_runtime) | |
end | |
end |
NewerOlder