諸事情で自宅鯖ちゃんが死んだのでノリでさくら VPS 借りた — Gist
ひとまずは一番アクセスの多い Undersky を復活させつつ
Apache+Passenger から乗り換えるべく Nginx+Unicorn 環境を試行錯誤してみた
以下は Undersky における設定もとい作業ログ
設定はググって出てきたものを寄せ集めてコピペしてきただけである
諸事情で自宅鯖ちゃんが死んだのでノリでさくら VPS 借りた — Gist
ひとまずは一番アクセスの多い Undersky を復活させつつ
Apache+Passenger から乗り換えるべく Nginx+Unicorn 環境を試行錯誤してみた
以下は Undersky における設定もとい作業ログ
設定はググって出てきたものを寄せ集めてコピペしてきただけである
class ApiLogger < Grape::Middleware::Base | |
def before | |
Rails.logger.info "[api] Requested: #{request_log_data.to_json}\n" + | |
"[api] #{response_log_data[:description]} #{response_log_data[:source_file]}:#{response_log_data[:source_line]}" | |
end | |
private | |
def request_log_data |
Notes on how to use AWS SNS: | |
1. Subscribe an HTTP endpoint (i.e. http://myhost/sns_endpoint) on AWS Console | |
2. AWS will send subscription confirmation right away | |
3. SNS_controller responds to subscription confirmation by sending confirmation using Fog. | |
4. Once AWS is happy, you can start sending notifications to your end point via SNS. |
location xxxx { | |
proxy_pass http://localhost:9000; | |
proxy_buffering off; | |
proxy_cache off; | |
proxy_redirect off; | |
proxy_set_header Connection ''; | |
proxy_http_version 1.1; | |
chunked_transfer_encoding off; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; |
# Vendor | |
#= require angular-1.0.5/angular | |
#= require angular-1.0.5/angular-resource | |
#= require angular-ui-bootstrap | |
# Angular | |
#= require assets | |
#= require_self | |
#= require_tree ./services | |
#= require_tree ./filters | |
#= require_tree ./directives |
/* | |
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp | |
server, but for some reason omit a client connecting to it. I added an | |
example at the bottom. | |
Save the following server in example.js: | |
*/ | |
var net = require('net'); |
Create droplet of your liking (ubuntu 12.10 x32)
ssh to root in terminal with your server ip
ssh [email protected]
Add ssh fingerprint and enter password provided in email
"Russian-Doll Caching" is great. It embraces the Rails (and Ruby) goal to "make the developer happy". And it does. Not having to worry about cache expiration is superb.
It has its limits, though. If you're trying to avoid any database queries, russian-doll caching will not work for you. If you are trying to represent thousands, or even hundreds, of objects under a single cache fragment, russian-doll caching is not the best option.
We use it whenever it makes sense, but sometimes we just have to bite the bullet and expire a cache fragment manually. When you want to start manually expiring cache on a fairly busy website, you have to start considering race conditions. I recently ran into the following scenario:
class Post < ActiveRecord::Base
after_save :expire_cache
module PgArrayHstoreFix | |
def self.included(base) | |
base.class_eval do | |
before_save :serialize_array_hash | |
end | |
def serialize_array_hash | |
self.class.attribute_names.each do |attribute| | |
column_definition = self.column_for_attribute(attribute) | |
if column_definition.array && column_definition.type == :hstore |