aboutsummaryrefslogtreecommitdiff
path: root/nginx_unicorn
diff options
context:
space:
mode:
authorMiquel Sabaté <mikisabate@gmail.com>2013-11-30 17:28:25 +0100
committerMiquel Sabaté <mikisabate@gmail.com>2013-11-30 17:28:25 +0100
commit267403fe5d1e1142d54c6d699f8deeac2a3334ec (patch)
tree76c3bb69125a9752636c9e63cbf04c7579cda5e5 /nginx_unicorn
parentf198c41756a408a0b4b4e9769c778fed8abd944f (diff)
downloaddotfiles-267403fe5d1e1142d54c6d699f8deeac2a3334ec.tar.gz
dotfiles-267403fe5d1e1142d54c6d699f8deeac2a3334ec.zip
Removed the NGinx + Unicorn config files.
These files were outdated. Anyways, I think that this kind of files shouldn't be placed in a "dotfiles" repo.
Diffstat (limited to 'nginx_unicorn')
-rw-r--r--nginx_unicorn/README.rdoc68
-rw-r--r--nginx_unicorn/nginx.http.conf18
-rw-r--r--nginx_unicorn/nginx.server.conf44
-rw-r--r--nginx_unicorn/nginx.service14
-rwxr-xr-xnginx_unicorn/nginxman.sh64
-rw-r--r--nginx_unicorn/unicorn.rb62
-rwxr-xr-xnginx_unicorn/unicorn_init.sh72
7 files changed, 0 insertions, 342 deletions
diff --git a/nginx_unicorn/README.rdoc b/nginx_unicorn/README.rdoc
deleted file mode 100644
index 9c5430f..0000000
--- a/nginx_unicorn/README.rdoc
+++ /dev/null
@@ -1,68 +0,0 @@
-= Nginx / Unicorn
-
-== Words of Warning
-
-I have decided to upload the configuration of my Nginx/Unicorn setup. Please
-be aware that:
-
-- I'm using Archlinux and, therefore, the directory hierarchy may change (even for other Linux distros such as Ubuntu).
-- I'll assume that your Rails app is located at /home/mssola/myapp, change it at your own needs.
-- I'm not saying that NGinx/Unicorn is the best combo ever. Be sure to understand what is NGinx and Unicorn before going any further.
-
-== Setting up NGinx
-
-My Nginx configuration may seem tricky but it's quite clean. My point is that
-you just want to have a basic configuration on your /etc/nginx/conf directory
-and then enable sites by linking more configuration (specific for each app)
-inside the /etc/nginx/sites-enabled directory (not created by default). Here
-it goes:
-
- # Setting up the basic HTTP configuration
-
- $ sudo cp -f nginx.http.conf /etc/nginx/conf/nginx.conf
- $ sudo mkdir /etc/nginx/sites-enabled
-
- # Copy the nginx.server.conf to your Rails application config directory.
- # After doing this, you have to edit this file and change the root with
- # the public path of your Rails application (in our case /home/mssola/myapp/public).
- # You also want to change the upstream unicorn block by replacing the 'my_app_name'
- # with the name of your app.
-
- $ cp nginx.server.conf /home/mssola/myapp/config/nginx.conf
- $ vim /home/mssola/myapp/config/nginx.conf
-
- # Finally create a soft link pointing to the specific configuration file for
- # this new site we want to enable.
-
- $ sudo ln -s /home/mssola/myapp/config/nginx.conf /etc/nginx/sites-enabled/my_app_name
-
-After going through the steps shown above, you should be able to start the
-nginx daemon successfully. If you try to access to localhost you'll see the
-500 page because Unicorn is not configured yet, but at least it proves that
-NGinx is properly running.
-
-== Setting up Unicorn
-
-My Unicorn configuration assumes that you want as many worker processes as
-CPU cores you have (using a linux-specific command). In order to change this and
-more, please configure the unicorn.rb file. In this file you also have to
-change the working directory (WD constant) with the path of your Rails
-application (/home/mssola/myapp in our case). Don't forget to replace all
-the 'my_app_name' with the name of your app. After editing this file, you
-have to edit the unicorn_init.sh script and change the APP_ROOT variable
-with the path of your Rails application (/home/mssola/myapp again :) ). I
-usually place both files to the config directory of my Rails
-application. However it's a good practice to copy the script file to the
-daemons directory in order to start unicorn at startup (assuming that you
-also start the nginx daemon at startup). With this script you can start,
-stop, upgrade, etc. Unicorn. In fact this script is quite similar to
-the example provided by the Unicorn folks.
-
-== What's next?
-
-Please be sure to understand what's going on the configurators. In order to
-fully understand it, check out the awesome documentation for the NGinx and
-Unicorn projects. Furthermore, there're more interesting unicorn configurators
-on the Unicorn repository, showing more possible scenarios and use cases.
-
-I hope this is helpful :)
diff --git a/nginx_unicorn/nginx.http.conf b/nginx_unicorn/nginx.http.conf
deleted file mode 100644
index 21bb36e..0000000
--- a/nginx_unicorn/nginx.http.conf
+++ /dev/null
@@ -1,18 +0,0 @@
-
-user http http;
-worker_processes 2;
-
-events {
- worker_connections 1024;
-}
-
-http {
- include mime.types;
- default_type application/octet-stream;
-
- sendfile on;
- tcp_nopush on;
- keepalive_timeout 65;
-
- include /etc/nginx/sites-enabled/*;
-}
diff --git a/nginx_unicorn/nginx.server.conf b/nginx_unicorn/nginx.server.conf
deleted file mode 100644
index 5d862b4..0000000
--- a/nginx_unicorn/nginx.server.conf
+++ /dev/null
@@ -1,44 +0,0 @@
-upstream unicorn {
- server unix:/tmp/unicorn.my_app_name.sock fail_timeout=0;
-}
-
-server {
- listen 80 default deferred;
- # server_name the_name_of_my_server;
-
- root /my/app/public/root;
- try_files $uri/index.html $uri @unicorn;
- location @unicorn {
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header Host $http_host;
- proxy_redirect off;
- proxy_pass http://unicorn;
- }
-
- error_page 500 502 503 504 /500.html;
- client_max_body_size 4G;
- keepalive_timeout 10;
-}
-
-# Same as above but with SSL & SPDY
-# server {
-# listen 80;
-# listen 443 ssl spdy;
-# server_name example.com;
-
-# ssl_certificate /etc/ssl/certs/my.ssl.crt;
-# ssl_certificate_key /etc/ssl/private/my.ssl.key;
-
-# root /my/app/public/root;
-# try_files $uri/index.html $uri @unicorn;
-# location @unicorn {
-# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-# proxy_set_header Host $http_host;
-# proxy_redirect off;
-# proxy_pass http://unicorn;
-# }
-
-# error_page 500 502 503 504 /500.html;
-# client_max_body_size 4G;
-# keepalive_timeout 10;
-# }
diff --git a/nginx_unicorn/nginx.service b/nginx_unicorn/nginx.service
deleted file mode 100644
index 8e28f0c..0000000
--- a/nginx_unicorn/nginx.service
+++ /dev/null
@@ -1,14 +0,0 @@
-[Unit]
-Description=A high performance web server and a reverse proxy server
-After=syslog.target network.target
-
-[Service]
-Type=forking
-PIDFile=/run/nginx.pid
-ExecStartPre=/usr/sbin/nginx -t -q -g 'pid /run/nginx.pid; daemon on; master_process on;'
-ExecStart=/usr/sbin/nginx -g 'pid /run/nginx.pid; daemon on; master_process on;'
-ExecReload=/usr/sbin/nginx -g 'pid /run/nginx.pid; daemon on; master_process on;' -s reload
-ExecStop=/usr/sbin/nginx -g 'pid /run/nginx.pid;' -s quit
-
-[Install]
-WantedBy=multi-user.target
diff --git a/nginx_unicorn/nginxman.sh b/nginx_unicorn/nginxman.sh
deleted file mode 100755
index 9df5e69..0000000
--- a/nginx_unicorn/nginxman.sh
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/bin/bash
-
-
-# Change this values to your own needs.
-_cfgdir=/etc/nginx
-_tmpdir=/var/lib/nginx
-_nginx=/tmp/nginx
-_version="default"
-_configure="./configure"
-_pwd=`pwd`
-
-
-# Fetch and extract NGinx
-if [ $_version == "default" ]; then
- echo -e "\033[32mFetching NGinx using hg (default)\033[0m"
- hg clone http://hg.nginx.org/nginx/ $_nginx
- _configure="./auto/configure"
-else
- echo -e "\033[32mFetching NGinx using wget ($_version)\033[0m"
- wget http://nginx.org/download/nginx-$_version.tar.gz
- tar xzvf nginx-$_version.tar.gz
- rm nginx-$_version.tar.gz
- mv nginx-$_version $_nginx
-fi
-cd $_nginx
-
-# Configure
-echo -e "\033[32mConfiguring\033[0m"
-$_configure \
- --prefix=$_cfgdir \
- --conf-path=$_cfgdir/nginx.conf \
- --sbin-path=/usr/sbin/nginx \
- --pid-path=/var/run/nginx.pid \
- --lock-path=/var/lock/nginx.lock \
- --user=http --group=http \
- --http-log-path=/var/log/nginx/access.log \
- --error-log-path=/var/log/nginx/error.log \
- --http-client-body-temp-path=$_tmpdir/client-body \
- --http-proxy-temp-path=$_tmpdir/proxy \
- --http-fastcgi-temp-path=$_tmpdir/fastcgi \
- --http-scgi-temp-path=$_tmpdir/scgi \
- --http-uwsgi-temp-path=$_tmpdir/uwsgi \
- --with-imap --with-imap_ssl_module \
- --with-ipv6 --with-pcre-jit \
- --with-file-aio \
- --with-http_dav_module \
- --with-http_geoip_module \
- --with-http_gzip_static_module \
- --with-http_realip_module \
- --with-http_ssl_module \
- --with-http_spdy_module \
- --with-http_stub_status_module \
- --with-cc-opt="-O3"
-
-# Compile & install
-echo -e "\033[32mCompiling\033[0m"
-make -j 4
-echo -e "\033[32mInstalling\033[0m"
-sudo make install
-sudo mkdir -p /var/lib/nginx
-
-# Cleanup
-echo -e "\033[32mCleaning up\033[0m"
-rm -rf $_nginx
diff --git a/nginx_unicorn/unicorn.rb b/nginx_unicorn/unicorn.rb
deleted file mode 100644
index 09bea64..0000000
--- a/nginx_unicorn/unicorn.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-##
-# This is the configuration file for Unicorn.
-
-
-# Feel free to change any of the following constants for your app:
-WD = '/my/app/root'
-NCORES = `cat /proc/cpuinfo | grep 'cores' | uniq | sed 's/[^0-9]//g'`.to_i
-
-# Setting up the working directory and some paths
-working_directory WD
-pid "#{WD}/tmp/pids/unicorn.pid"
-stderr_path "#{WD}/log/unicorn.my_app_name.sock"
-stdout_path "#{WD}/log/unicorn.my_app_name.sock"
-
-# We want one worker per core.
-worker_processes NCORES
-
-# Listen on a Unix domain socket. I'm using a shorter backlog
-# for quicker failover when busy.
-listen '/tmp/unicorn.my_app_name.sock', backlog: 64
-
-# nuke workers after 30 seconds instead of 60 seconds (the default)
-timeout 30
-
-# Preloading app for memory saving on COW-friendly GC's
-preload_app true
-GC.respond_to?(:copy_on_write_friendly=) and
- GC.copy_on_write_friendly = true
-
-
-before_fork do |server, worker|
- ##
- # The following is highly recomended for Rails + "preload_app true"
- # as there's no need for the master process to hold a connection
- defined?(ActiveRecord::Base) and
- ActiveRecord::Base.connection.disconnect!
-
- ##
- # When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
- # immediately start loading up a new version of itself (loaded with a new
- # version of our app). When this new Unicorn is completely loaded
- # it will begin spawning workers. The first worker spawned will check to
- # see if an .oldbin pidfile exists. If so, this means we've just booted up
- # a new Unicorn and need to tell the old one that it can now die. To do so
- # we send it a QUIT.
- #
- # Using this method we get 0 downtime deploys.
- old_pid = "#{WD}/tmp/pids/unicorn.pid.oldbin"
- if File.exists?(old_pid) && server.pid != old_pid
- begin
- Process.kill("QUIT", File.read(old_pid).to_i)
- rescue Errno::ENOENT, Errno::ESRCH
- # someone else did our job for us
- end
- end
-end
-
-after_fork do |server, worker|
- # The following is *required* for Rails + "preload_app true",
- defined?(ActiveRecord::Base) and
- ActiveRecord::Base.establish_connection
-end
diff --git a/nginx_unicorn/unicorn_init.sh b/nginx_unicorn/unicorn_init.sh
deleted file mode 100755
index 52ccf9f..0000000
--- a/nginx_unicorn/unicorn_init.sh
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/sh
-set -e
-# Example init script, this can be used with nginx, too,
-# since nginx and unicorn accept the same signals
-
-# Feel free to change any of the following variables for your app:
-TIMEOUT=${TIMEOUT-60}
-APP_ROOT=/my/app/root
-PID=$APP_ROOT/tmp/pids/unicorn.pid
-RAILS_ENV="development"
-CMD="/usr/bin/unicorn -D -c $APP_ROOT/config/unicorn.rb -E $RAILS_ENV"
-action="$1"
-set -u
-
-old_pid="$PID.oldbin"
-
-cd $APP_ROOT || exit 1
-
-sig () {
- test -s "$PID" && kill -$1 `cat $PID`
-}
-
-oldsig () {
- test -s $old_pid && kill -$1 `cat $old_pid`
-}
-
-case $action in
-start)
- sig 0 && echo >&2 "Already running" && exit 0
- su -c "$CMD" - mssola
- ;;
-stop)
- sig QUIT && exit 0
- echo >&2 "Not running"
- ;;
-force-stop)
- sig TERM && exit 0
- echo >&2 "Not running"
- ;;
-restart|reload)
- sig HUP && echo reloaded OK && exit 0
- echo >&2 "Couldn't reload, starting '$CMD' instead"
- su -c "$CMD" - mssola
- ;;
-upgrade)
- if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
- then
- n=$TIMEOUT
- while test -s $old_pid && test $n -ge 0
- do
- printf '.' && sleep 1 && n=$(( $n - 1 ))
- done
- echo
-
- if test $n -lt 0 && test -s $old_pid
- then
- echo >&2 "$old_pid still exists after $TIMEOUT seconds"
- exit 1
- fi
- exit 0
- fi
- echo >&2 "Couldn't upgrade, starting '$CMD' instead"
- su -c "$CMD" - mssola
- ;;
-reopen-logs)
- sig USR1
- ;;
-*)
- echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"
- exit 1
- ;;
-esac