Git Product home page Git Product logo

deploy_pin's People

Contributors

dependabot[bot] avatar dovganych avatar drowze avatar emilio-santiago avatar marikrebega avatar serhii-bodnaruk avatar skcc321 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

deploy_pin's Issues

recurring jobs & deployment state track

Deploy pin lacks of recurring tasks & deployment state track.

# frozen_string_literal: true

DeployPin.setup do
  tasks_path "deploy_pin"
  groups %w[pre I II III rollback]
  fallback_group "III"
  statement_timeout 10.minutes
  deployment_state track: true, ongoing: %w[pre III], pending: "rollback"

  # hide in deploy pin library
  def self.ongoing_deployment?
    deployment_state == "ongoing"
  end

  def self.ongoing_deployment?
    deployment_state == "pending"
  end
  
  def self.deployment_state
    if Thread.current[:deploy_pin][:deployment].blank? ||
      Thread.current[:deploy_pin][:deployment][:expiration] < Time.current
      Thread.current[:deploy_pin][:deployment] = {
        expiration: 5.minutes.from,
        state: Rails.cache.read("deploy_pin:deployment")
      }
    end

    Thread.current[:deploy_pin][:deployment][:state]
  end
end

usage examples:

  • there should be a new directory always running tasks (./deploy_pin/always/ )
  • deployment "ongoing", and "rollback" should be hidden from the end user.
# we are not going to store them in the DB
# 1:pre
# task_title: TurnOn

Rails.cache.write("deploy_pin:deployment", "ongoing")
# 1:post
# task_title: TurnOff

Rails.cache.delete("deploy_pin:deployment")
# 1:rollback
# task_title: TurnOn

Rails.cache.write("deploy_pin:deployment", "pending")

the release flow:

  1. bundle exec deploy_pin run["pre"]
  2. db:migrate
  3. release the app
  4. bundle exec deploy_pin run

the rollback flow:

  1. bundle exec deploy_pin run["rollback"]
  2. rollback the app

bundle exec rake deploy_pin:cleanup

Missing feature to cleanup historical tasks.

DeployPin.config do
  cleanup_safe_timewindow 2.month
  ...
end
bundle exec rake deploy_pin:cleanup # removes all deploy_pin files older then 2.months

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.