When something goes wrong I want to degrade the user experience (instead of returning a 500 - Server Error) And I want to be notified about the failure
Wrap non mission critical code:
# Check server process is using jemalloc | |
# ref. [Japanese] https://tech.studyplus.co.jp/entry/2019/09/09/094140 | |
class AppController < ActionController::Base | |
def show | |
r = `strings /proc/#{Process.pid}/maps | grep jemalloc` | |
render plain: "<h1>#{ENV['LD_PRELOAD'].presence || 'empty'}</h1><pre>#{r}</pre>" | |
end | |
end |
# 1) Put 's3' gem in Gemfile. | |
# 2) Create as3.yml configuration for S3 | |
# 3) Create initializer for as3.yml | |
# 4) Make "assets" folder inside your bucket | |
# 5) After running task run "RAILS_ENV=production rake assets:precompile" | |
# 6) Invoke task by running "rake as3:upload" | |
namespace :as3 do | |
desc "Uploads compiled assets (public/assets) to Amazone AS3" | |
task :upload do |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet"> | |
<style> | |
.sidebar { | |
width: 5rem; /* Adjust the width as needed */ | |
height: 100vh; |
require "active_record" | |
namespace :db do | |
db_config = YAML::load(File.open('config/database.yml')) | |
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'}) | |
desc "Create the database" | |
task :create do | |
ActiveRecord::Base.establish_connection(db_config_admin) |
require 'sinatra' | |
require "sinatra/reloader" if development? | |
require 'http' | |
require 'json' | |
# https://www.linkedin.com/developers/apps | |
class Settings | |
CLIENT_ID = '...' | |
CLIENT_SECRET = '...' | |
ACCESS_TOKEN = '...' |
class Graph | |
def initialize | |
@graph = { | |
"Odin" => [["Thor", 1], ["Heimdall", 1]], | |
"Fregg" => [["Heimdall", 1], ["Thor", 1]], | |
"Heimdall" => [["Odin", 1], ["Fregg", 1]], | |
"Thor" => [["Odin", 1], ["Loki", 1], ["Fregg", 1]], | |
"Loki" => [["Thor", 1]] | |
} | |
end |
# unlogged tables used to speedup tests, but its are not crash proof | |
config.to_prepare do | |
ActiveSupport.on_load(:active_record) do | |
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables = true | |
end | |
end |
http://site.com http://www.site.com https://www.site.com { | |
redir https://site.com{uri} | |
} | |
https://site.com { | |
root * /var/www/site/current/public | |
log { | |
output file /var/www/site/shared/log/access.log { | |
roll_size 10MB |