Skip to content

Instantly share code, notes, and snippets.

View grammakov's full-sized avatar
🤔
THINK

Denis grammakov

🤔
THINK
View GitHub Profile
# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database superuser can access the database using some other method.
# Noninteractive access to all databases is required during automatic
# maintenance (custom daily cronjobs, replication, and similar tasks).
#
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
### Nginx ###
check process nginx with pidfile /opt/nginx/logs/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host 127.0.0.1 port 80 protocol http
then restart
if 3 restarts within 5 cycles then timeout
# paths
app_path = "/home/deployer/qna"
working_directory "#{app_path}/current"
pid "#{app_path}/current/tmp/pids/unicorn.pid"
# listen
listen "/tmp/unicorn.qna.sock", :backlog => 64
# logging
stderr_path "log/unicorn.stderr.log"

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create Droplet

Create droplet of your liking (ubuntu 12.10 x32)

Setup DNS

On Digital Ocean, create a DNS entry for your server (xyz.com)

Make sure it has NS records that use digital oceans nameservers

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
<!--
.ReadMsgBody {width: 100%;background-color: #1d1d1d;}
.ExternalClass {width: 100%;background-color: #1d1d1d;}
html {width: 100%;padding: 0px;margin: 0px;}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CH Daily for 11 September 2015</title>
<link href="https://s3.amazonaws.com/sendicate-app/uploads/p/uploaded_assets/attachments/000/000/562/original/hide_preheader.css?utm_source=sendicate&amp;utm_medium=email&amp;utm_campaign=2015-09-11+CH+Daily+for+11+September+2015" media="screen" rel="stylesheet" data-immutable type="text/css">
<style type="text/css" data-immutable>
@media only screen and (max-width: 480px) {
img {
max-width:280px !important;
max-height:inherit !important;
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
<!--
.ReadMsgBody {width: 100%;background-color: #1d1d1d;}
.ExternalClass {width: 100%;background-color: #1d1d1d;}
html {width: 100%;padding: 0px;margin: 0px;}
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'capybara/poltergeist'
Capybara.default_driver = :poltergeist
Capybara.run_server = false
module GetTitle
class WebScraper
@grammakov
grammakov / nginx-passenger-ssl.conf
Created May 19, 2017 09:22 — forked from rkjha/nginx-passenger-ssl.conf
Nginx/Passenger config when using SSL with a Ruby/Rails Application.
# for redirecting hhtp traffic to https version of the site
server {
listen 80;
server_name example.com;
return 301 https://$server_name$request_uri;
}
# for redirecting to non-www version of the site
server {
listen 80;
@grammakov
grammakov / turbo_turbo.js.coffee
Created June 20, 2017 07:19 — forked from dv/turbo_turbo.js.coffee
Fix setTimout, setInterval, and global ajax requests when using Turbolinks
# This library fixes common problems with turbolinks
# - Overwrite setTimeout and setInterval to intercept generated ID's
# - Keep track of Ajax requests
#
# When turbolinks' unload event is called, we:
# - Cancel all setTimeouts and setIntervals
# - Abort all still running Ajax requests
$.turboTurbo =