Skip to content

Instantly share code, notes, and snippets.

class DashboardMiddleware
def call(worker_instance, queue, sqs_msg, body)
# send before process information
yield
# send after process information
rescue Exception => e
# send exception information
end
end
# rescue...
data = {
id: sqs_msg.attributes['SentTimestamp'].to_i,
worker: worker_instance.class.to_s,
queue: queue,
arguments: body,
enqueued_at: Time.at(sqs_msg.attributes['SentTimestamp'].to_i / 1000)
}
REDIS.lpush("sqs-dashboard-failures", data)
# end
@epintos
epintos / README.md
Last active August 29, 2015 14:22
Pre push github hook

Run:

  • chmod +x pre-push.sh
  • ln -s ../../pre-push.sh .git/hooks/pre-push

and the script will be executed before each git push. You can skip the hook by adding --no-verify to your git push.

@epintos
epintos / Dockerfile
Created June 25, 2015 23:46
Ruby on Rails Continuous Integration with Jenkins and Docker Compose
FROM ruby:2.2.2
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Install RMagick
# RUN apt-get install -y libmagickwand-dev imagemagick
# Install Nokogiri
# RUN apt-get install -y zlib1g-dev
RUN mkdir /myapp
@epintos
epintos / database.yml
Last active August 29, 2015 14:23
Ruby on Rails Continuous Integration with Jenkins and Docker Compose
development: &default
adapter: postgresql
encoding: unicode
database: your-project_development
pool: 5
username: <%= ENV.fetch('DB_USERNAME', 'your-project') %>
password: <%= ENV.fetch('DB_PASSWORD', 'your-project') %>
host: <%= ENV.fetch('DB_1_PORT_5432_TCP_ADDR', 'localhost') %>
port: <%= ENV.fetch('DB_1_PORT_5432_TCP_PORT', '5432') %>
@epintos
epintos / [Jenkins] Build Execute Shell MongoId
Created June 25, 2015 23:48
Ruby on Rails Continuous Integration with Jenkins and Docker Compose
cat >config/mongoid.yml <<EOF
test:
sessions:
default:
database: ${JOB_NAME}_test
hosts:
- <%= "#{ENV['DB_1_PORT_27017_TCP_ADDR']}:#{ENV['DB_1_PORT_27017_TCP_PORT']}" %>
EOF
@epintos
epintos / unicorn_init.erb
Created July 11, 2015 18:42
Ruby on Rails deploy with Capistrano 3
#!/bin/bash
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Manage unicorn server
# Description: Start, stop, restart unicorn server for a specific application.
### END INIT INFO
@epintos
epintos / production.rb
Created July 11, 2015 18:43
Ruby on Rails deploy with Capistrano 3
set :stage, :production
role :app, %w(user@url)
role :web, %w(user@url)
role :db, %w(user@url)
set :bundle_binstubs, -> { shared_path.join('bin') }
set :ssh_options, keys: %w(~/.ssh/your-project-production.pem), forward_agent: true
@epintos
epintos / Capfile
Created July 11, 2015 18:41
Ruby on Rails deploy with Capistrano 3
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rbenv'
require 'capistrano/rbenv_install'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/nginx_unicorn'
require 'capistrano/sidekiq'
require 'whenever/capistrano'
@epintos
epintos / deploy.rb
Created July 11, 2015 18:40
Ruby on Rails deploy with Capistrano 3
# Config valid only for Capistrano 3.2.1
lock '3.2.1'
set :application, 'your-project'
set :repo_url, 'git@github.com:organization/your-repository.git'
ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
set :scm, :git
set :deploy_to, "/home/ubuntu/apps/#{fetch(:application)}"