Oct 16 2010
- 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments
In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].
| module QC | |
| class Worker | |
| MAX_LOCK_ATTEMPTS = ENV["QC_MAX_LOCK_ATTEMPTS"] || 5 | |
| def initialize | |
| @running = true | |
| @queue = QC::Queue.new(ENV["QUEUE"]) | |
| handle_signals | |
| end |
| def lock_job | |
| attempts = 0 | |
| job = nil | |
| until job | |
| job = @queue.dequeue | |
| if job.nil? | |
| attempts += 1 | |
| if attempts < MAX_LOCK_ATTEMPTS | |
| sleep(2**attempts) | |
| next |
| abacus.go | |
| Log Messages | |
| All of our production systems in The Vault have their | |
| STDOUT connected to Heroku's logplex. We also connect | |
| syslog draings to Logplex that outlet all messages to | |
| PaperTrailapp. Each system outputs two classes of | |
| messages. The first class of message is the system | |
| class. Messages of the system class are originated by |
| # Streams of Data Part I | |
| ## Logging Basics | |
| # We don't need anything complex here. | |
| # We will use the logger in the stdlib. | |
| # Rails.logger works fine here as well. | |
| # Using Rails.logger is prefered as you won't muck up | |
| # the screen when running tests. | |
| require 'logger' |
| # Tab completion for tmux sessions. | |
| # Quickly open new tmux sessions in your projects dir. | |
| # Setup: | |
| # Source this code in your bash shell. | |
| # Update the code_dir var with the root directory of your source code. | |
| # Usage: | |
| # Use the tab to open an existing session. |
| CREATE OR REPLACE FUNCTION last_day(timestamptz) | |
| RETURNS timestamptz AS | |
| $$ | |
| SELECT (date_trunc('MONTH', $1) + INTERVAL '1 MONTH - 1 day'); | |
| $$ LANGUAGE 'sql' IMMUTABLE STRICT; | |
| CREATE OR REPLACE FUNCTION first_day(timestamptz) | |
| RETURNS timestamptz AS | |
| $$ | |
| SELECT date_trunc('MONTH', $1); |
| #!/usr/bin/env sh | |
| curl -lo beanstalkd.tar.gz "http://cloud.github.com/downloads/kr/beanstalkd/beanstalkd-1.4.6.tar.gz" | |
| tar xvzf beanstalkd.tar.gz | |
| cd beanstalkd-1.4.6/ | |
| ./configure | |
| make | |
| python -m SimpleHTTPServer $PORT | |
WIP
This document is still a work in process. Please email: [email protected] for ideas and contributions.
The PAAS revolution has paved a way for a new class of internet business. Platform services like: Heroku, WebSolr & Joyent are breaking barriers for application developers by removing the burden of server management.