Skip to content

Instantly share code, notes, and snippets.

View amgorb's full-sized avatar
🦄

Andrey Mikhaltsov amgorb

🦄
  • OneTwoTrip
  • Moscow
View GitHub Profile
@amgorb
amgorb / uwsgi.conf
Created April 11, 2018 16:37
uWSGI separate JSON logging for application compatible with Elasticsearch
[uwsgi]
;this will encode uwsgi messages into JSON, encode requests to JSON and leave application output unchanged
;if this output from application has msgName string
logger = default stdio
logger = secondlogger stdio
log-route = secondlogger msgName
log-route = default ^((?!msgName).)*$
log-encoder = json:default {"@timestamp":"${strftime:%%Y-%%m-%%dT%%H:%%M:%%S.666Z}","source":"uwsgi", "message":"${msg}"}
@amgorb
amgorb / iterm_launch_ssh_in_tabs.scpt
Created May 16, 2017 10:40
small applescript that will launch iterm and open several tabs and run ssh connection to each server in list
--
(*
this small script will launch iterm and open several tabs and run ssh connection to each server in list
*)
set servers to {"sandbox-19", "sandbox-19", "sandbox-19", "sandbox-19"}
tell application "iTerm"
activate
tell the first window
repeat with server in servers
@amgorb
amgorb / nginx.conf
Created April 13, 2017 13:21
poors man debugging nginx internals and lua variables, will log nginx variable to error_log
nginx.conf:
...
log_by_lua_block {
ngx.log(ngx.ERR,ngx.var.request_uri)
ngx.log(ngx.ERR,ngx.req.get_headers()["Cookie"])
}
...
@amgorb
amgorb / redis-client-ouput-buffer-limit
Created February 20, 2017 16:19
redis replication scheduled to be closed ASAP for overcoming of output buffer limits.
If you redis initial replication fails with error like
"5101:M 20 Feb 18:14:29.130 # Client id=4500196 addr=71.459.815.760:43872 fd=533 name= age=127 idle=127 flags=S db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=13997 oll=1227 omem=192281275 events=rw cmd=psync scheduled to be closed ASAP for overcoming of output buffer limits.
means that slave buffer is not enough and you should increase it (at master!) with command like
redis-cli config set client-output-buffer-limit "slave 836870912 836870912 0"
more info: https://redis.io/topics/clients
@amgorb
amgorb / gist:774aad7d5168e60ca0cdce7c6839ce01
Created December 2, 2016 16:56
haproxy SSL in big cluster
If you have many hosts glued together by SSL haproxy you may encounder high CPU usage - that is because defaul TLS cache is not enough
to hold all keys and they regenerate each connection.
Solution is to increase tune.ssl.cachesize parameter.
I have Lua script that manipulates cookies and headers based at GET parameters.
This script didnt work well at one location, strangely the ngx.var.args was empty with ordinary request.
The trick was that in location we have:
location /x/ {
header_filter_by_lua_file /etc/nginx/lua/referrer_cookie.lua;
rewrite ^/x/(.*) /$1 break;
try_files $uri /x/index.htm;
@amgorb
amgorb / newrelic.txt
Last active May 25, 2016 17:59
NewRelic Centos 7
Sometimes newrelic fails to connect to local agent at CentOS 7 server.
That is because newrelic-daemon do not listen at ipv6 address:
( newrelic.daemon.port = 8888 )
typical errors from log files are:
warning: daemon connect(fd=6 port=8888) returned -1 errno=ECONNREFUSED. Failed to connect to the newrelic-daemon. Please make sure that there is a properly configured newrelic-daemon running. For additional assistance, please see: https://newrelic.com/docs/php/newrelic-daemon-startup-modes
and