##Working configuration to accomplish 0-downtime deploy with unicorn 5.x and systemd on centos 7
The scope is to accomplish a 0-downtime reload of a unicorn service managed by Systemd on a Centos 7 distro.
The examples and assumptions that i found on the bogomips's unicorn repo seems not working for centos 7.
Below a working configuration tested on Centos 7 and unicorn 5.1
Any advice/remark will be appreciated
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Retriable | |
# This will catch any exception and retry twice (three tries total): | |
# with_retries { ... } | |
# | |
# This will catch any exception and retry four times (five tries total): | |
# with_retries(:limit => 5) { ... } | |
# | |
# This will catch a specific exception and retry once (two tries total): | |
# with_retries(Some::Error, :limit => 2) { ... } | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D | |
rails_env = ENV['RAILS_ENV'] || 'production' | |
# 16 workers and 1 master | |
worker_processes (rails_env == 'production' ? 16 : 4) | |
# Load rails+github.git into the master before forking workers | |
# for super-fast worker spawn times | |
preload_app true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package utility; | |
import java.awt.*; | |
import java.awt.datatransfer.StringSelection; | |
import java.awt.event.KeyEvent; | |
import org.apache.commons.lang3.SystemUtils; | |
import org.openqa.selenium.WebElement; | |
public class CommonUtils { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.security.NoSuchAlgorithmException; | |
import java.util.Base64; | |
import javax.crypto.KeyGenerator; | |
import javax.crypto.SecretKey; | |
public class CryptoKeyGenerator { | |
public static void main(String[] args) throws NoSuchAlgorithmException { | |
SecretKey key = KeyGenerator.getInstance("AES").generateKey(); | |
String encodedKey = Base64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Api::V3::BaseController < ActionController::Base | |
include Limiter | |
before_action -> { rate_limit(key: "api_#{doorkeeper_token.application_id}", rate: 60, interval: 60) } | |
private | |
def handle_rate_limit_exception | |
log_exception RateLimitError.new("Rate limit reached for #{doorkeeper_token.application.name}") | |
render json: { error: { type: "rate_limit_exceeded", message: "Rate limit exceeded." } }, status: 429 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module OneTimePassword | |
# Concern containing logic and methods for OTP authentication. | |
# Is used Time-based One-time Password Algorithm(TOTP) | |
# https://tools.ietf.org/html/rfc6238 | |
extend ActiveSupport::Concern | |
OTP_DIGITS = 6 | |
OTP_NUMBER_OF_BACKUP_CODES = 10 | |
OTP_BACKUP_CODE_LENGTH = 12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ApplicationController.allow_forgery_protection = false | |
app.post('/users/sign_in', {"users"=>{"email"=>"sam@example.com", "password"=>"password"}}) |