- HTTP server
nginx
- Rails web server
passenger
- Database
PosgreSQL
- Deployment utility
mina
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### ssh to root in terminal with your server ip | |
ssh root@123.123.123.123 | |
### Create new user | |
adduser deploy | |
### Set new users privileges | |
visudo | |
### Find user privileges section |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
install_elasticsearch() { | |
echo " * -- Elasticsaerch -- *" | |
echo " * Update" | |
sudo apt-get -qq -y update | |
echo " * Install JDK" | |
sudo apt-get -qq -y install openjdk-7-jre-headless | |
echo " * Download deb (V1.4.2)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ Form excerpt | |
= f.button t(".save"), class: "btn" | |
= f.button t(".publish"), class: "btn", name: "publish" | |
= f.button t(".test"), class: "btn", name: "test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/image.rb | |
class Image < ActiveRecord::Base | |
has_many :taggings, :as => :taggable | |
has_many :tags, :through => :taggings | |
end |
There are 4 parts:
- the html partial which goes into your layout
- the scss block to add to your stylesheet
- the coffeescript to add to your application.coffee
- the image. The image is not included here, but go here and "Save image": http://aragats.herokuapp.com/assets/ajax-loader.gif - or go here http://www.ajaxload.info/ and generate your own loader image.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/tasks/db.rake | |
namespace :db do | |
desc "Dumps the database to db/APP_NAME.dump" | |
task :dump => :environment do | |
cmd = nil | |
with_config do |app, host, db, user| | |
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump" | |
end | |
puts cmd |
Moved to git repository: https://github.com/denji/nginx-tuning
For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.
Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon
with HyperThreading enabled, but it can work without problem on slower machines.
You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Attachment < ActiveRecord::Base | |
mount_uploader :attachment, AttachmentUploader | |
# Associations | |
belongs_to :attached_item, polymorphic: true | |
# Validations | |
validates_presence_of :attachment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem('mysql2') | |
gem('compass') | |
gem('zurb-foundation') | |
gem('puma') | |
gem('dalli') | |
gem('omniauth') | |
gem('omniauth-twitter') | |
gem('health_check') | |
gem('kaminari') | |
gem('newrelic_rpm') |