Skip to content

Instantly share code, notes, and snippets.

View ramezanpour's full-sized avatar
☀️
Learning...

Mohammad Mahdi Ramezanpour ramezanpour

☀️
Learning...
View GitHub Profile
@ramezanpour
ramezanpour / post-mortem.md
Created March 12, 2018 09:02 — forked from joewiz/post-mortem.md
Recovery from nginx "Too many open files" error on Amazon AWS Linux

On Tue Oct 27, 2015, history.state.gov began buckling under load, intermittently issuing 500 errors. Nginx's error log was sprinkled with the following errors:

2015/10/27 21:48:36 [crit] 2475#0: accept4() failed (24: Too many open files) 2015/10/27 21:48:36 [alert] 2475#0: *7163915 socket() failed (24: Too many open files) while connecting to upstream...

An article at http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/ provided directions that mostly worked. Below are the steps we followed. The steps that diverged from the article's directions are marked with an *.

    • Instead of using su to run ulimit on the nginx account, use ps aux | grep nginx to locate nginx's process IDs. Then query each process's file handle limits using cat /proc/pid/limits (where pid is the process id retrieved from ps). (Note: sudo may be necessary on your system for the cat command here, depending on your system.)
  1. Added fs.file-max = 70000 to /etc/sysctl.conf
  2. Added `nginx soft nofile 1
@ramezanpour
ramezanpour / delete_merged_branches.sh
Last active February 12, 2018 08:32 — forked from hoseinit/Git clean deleted Branches
Remove Merged Branches from Local Git
// Gitlab projects
git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d
//or on Github projects:
git branch --merged | grep -v '*' | xargs git branch -d
@ramezanpour
ramezanpour / add_database.sql
Last active February 12, 2018 13:02
Create a database and user in my sql and grant access to it
CREATE DATABASE mydatabase CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON [database] . * TO 'newuser'@'localhost';
GRANT ALL PRIVILEGES ON [database].* TO 'newuser'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;