Skip to content

Instantly share code, notes, and snippets.

@bmnick
Created March 3, 2011 17:56
Show Gist options
  • Select an option

  • Save bmnick/853183 to your computer and use it in GitHub Desktop.

Select an option

Save bmnick/853183 to your computer and use it in GitHub Desktop.
nesta new <yoursitename> --git
ln -s `pwd`/<yoursitename> /var/www/nesta
cd <yoursitename>
mkdir log
mkdir tmp
mkdir tmp/sockets
mkdir tmp/pids
upstream app_server {
server unix:/var/www/nesta/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name <your_domain>;
keepalive_timeout 5;
access_log /var/log/nginx/nesta.access.log;
root /var/www/nesta/public;
client_max_body_size 4G;
location / {
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://app_server;
break;
}
}
}
#!/bin/sh
### BEGIN INIT INFO
# Provides: nesta
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Daemon runninng nesta under a unicorn config
# Description: Daemon runninng nesta under a unicorn config
### END INIT INFO
UNICORN=/home/ubuntu/.rvm/bin/bootup_unicorn
CONFIG_FILE=/var/www/nesta/config/unicorn.rb
APP_HOME=/var/www/nesta
case "$1" in
start)
$UNICORN -c $CONFIG_FILE -E production -D
;;
stop)
kill -QUIT `cat #{APP_HOME}/tmp/pids/unicorn.pid`
;;
restart|force-reload)
kill -USR2 `cat ${APP_HOME}/tmp/pids/unicorn.pid`
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
:
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
rvm install 1.9.2
rvm gemset create nesta
rvm use 1.9.2@nesta
gem install unicorn bundler nesta
worker_processes 1
working_directory "/var/www/nesta/"
# This loads the application in the master process before forking
# worker processes
# Read more about it here:
# http://unicorn.bogomips.org/Unicorn/Configurator.html
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
timeout 30
# This is where we specify the socket.
# We will point the upstream Nginx module to this socket later on
listen "/var/www/nesta/tmp/sockets/unicorn.sock", :backlog => 64
pid "/var/www/nesta/tmp/pids/unicorn.pid"
# Set the path of the log files inside the log folder of the testapp
stderr_path "/var/www/nesta/log/unicorn.stderr.log"
stdout_path "/var/www/nesta/log/unicorn.stdout.log"
rvm wrapper 1.9.2@nesta bootup bundle
rvm wrapper 1.9.2@nesta bootup unicorn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment