Poetry of Programming

Its about Ruby on Rails – Kiran Soumya


Issue with Guard

I came across this error this morning, “The user limit on the total number of inotify watches was reached or the kernel failed to allocate a needed resource. (Errno::ENOSPC)”

Tried Guard ignore path to .git or tried reducing the watch files under Guardfile, but alas! Guard by default handles that ignore path of .git and still it throws the same crazy error…

Googled the issues under Guard gem, then realized that you need to increase the watch count for the current user on your box to fix this.
# Check current maximum
$ cat /proc/sys/fs/inotify/max_user_watches
# Increase the maximum
$ echo 100000|sudo tee /proc/sys/fs/inotify/max_user_watches
$ cat /proc/sys/fs/inotify/max_user_watches

This increases max_user_watches temporarily.On Ubuntu, to increase at boot, edit /etc/sysctl.conf and add fs.inotify.max_user_watches=100000.


Redirect Address/Path with Nginx

Here is the nginx config file which redirects

http://mysite/escapeme/blah =>  http://mysite:3000/blah

user www-data;
worker_processes  3;
error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;
events {
 worker_connections  1024;
http {
 include     /etc/nginx/mime.types;
 access_log  /var/log/nginx_access.log;
 sendfile        on;
 keepalive_timeout  65;
 tcp_nodelay        on;
 server {
 listen   *:80; ## listen for ipv4
 access_log  /var/log/nginx_access.log;
 location /escapeme {
 rewrite /escapeme(.*) $1 break;
 proxy_redirect     off;
 proxy_set_header   Host             $host;
 proxy_set_header   X-Real-IP        $remote_addr;
 proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;