Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Deployment Configuration

ZeroC0D3 Team edited this page Jan 20, 2018 · 1 revision

Deploy

User Configuration

  • Development / Staging
    /* ======================================= 
          USER CONFIGURATION 
       ======================================= */
    int NUM_RELEASE   = 10;               // Maximum Number of Release Folder 
    char ENV[64]      = "staging";        // Selected Environment (staging / production)
    int NUM_LOG_VIEW  = 50;               // Maximum Line Number Viewing Log 
    int RAILS_VERSION = 4;                // Rails Version (default: 5)
    int ENABLE_MIGRATION = 0;             // Force Enable Migration (0 = disable/default, 1 = enable)
    int ENABLE_BUNDLE_INSTALL  = 1;       // Enable Running "bundle install" (0 = disable/default, 1 = enable)
    int ENABLE_CLOBBER_ASSETS  = 1;       // Enable Running Clobber/Cleanup Assets (0 = disable/default, 1 = enable)
    int ENABLE_COMPILE_ASSETS  = 1;       // Enable Running Assets Precompile (0 = disable/default, 1 = enable)
    int ENABLE_FAYE_SERVICE    = 1;       // Enable Running Faye Service (0 = disable/default, 1 = enable)
    int ENABLE_MONGODB_SERVICE = 1;       // Enable Running MongoDB Service (0 = disable/default, 1 = enable)
    int ENABLE_PUSHR_SERVICE   = 1;       // Enable Running Pushr Service (0 = disable/default, 1 = enable)
    int ENABLE_REDIS_SERVICE   = 1;       // Enable Running Redis Service (0 = disable/default, 1 = enable)
    int ENABLE_SIDEKIQ_SERVICE = 1;       // Enable Running Sidekiq Service (0 = disable/default, 1 = enable)
    
    // Repository
    char REPO_NAME[1024] = "git@github.com:zeroc0d3/ruby-deploy-gcc.git";
    char REPO_BRANCH[64] = "master";
    
    // Shared Folders
    char *LIST_SHARED_FOLDERS[] = {
        "log",
        "tmp/cache",
        "tmp/pids",
        "tmp/sessions",
        "tmp/sockets",
        "vendor/assets",
        "public/assets",
        NULL
    };
    
    // Shared Files
    char *LIST_SHARED_FILES[] = {
        ".env",
        "faye.ru",
        "config/aws.yml",
        "config/database.yml",
        "config/mongoid.yml",
        "config/pushr-staging.yml",
        "config/pushr-production.yml",
        "config/secrets.yml",
        "config/sidekiq.yml",
        "config/unicorn/staging.rb",
        "config/unicorn/staging.rb",
        "config/unicorn/production.rb",
        "config/yourub.yml",
        NULL
    };
    
  • Production
    /* ======================================= 
          USER CONFIGURATION 
       ======================================= */
    int NUM_RELEASE   = 10;               // Maximum Number of Release Folder 
    char ENV[64]      = "production";     // Selected Environment (staging / production)
    int NUM_LOG_VIEW  = 50;               // Maximum Line Number Viewing Log 
    int RAILS_VERSION = 4;                // Rails Version (default: 5)
    int ENABLE_MIGRATION = 0;             // Force Enable Migration (0 = disable/default, 1 = enable)
    int ENABLE_BUNDLE_INSTALL  = 1;       // Enable Running "bundle install" (0 = disable/default, 1 = enable)
    int ENABLE_CLOBBER_ASSETS  = 1;       // Enable Running Clobber/Cleanup Assets (0 = disable/default, 1 = enable)
    int ENABLE_COMPILE_ASSETS  = 1;       // Enable Running Assets Precompile (0 = disable/default, 1 = enable)
    int ENABLE_FAYE_SERVICE    = 1;       // Enable Running Faye Service (0 = disable/default, 1 = enable)
    int ENABLE_MONGODB_SERVICE = 1;       // Enable Running MongoDB Service (0 = disable/default, 1 = enable)
    int ENABLE_PUSHR_SERVICE   = 1;       // Enable Running Pushr Service (0 = disable/default, 1 = enable)
    int ENABLE_REDIS_SERVICE   = 1;       // Enable Running Redis Service (0 = disable/default, 1 = enable)
    int ENABLE_SIDEKIQ_SERVICE = 1;       // Enable Running Sidekiq Service (0 = disable/default, 1 = enable)
    int CONF_WEB_SERVER        = 2;       // Default Running Webserver (1 = Unicorn, 2 = Puma / default)
    
    // Repository
    char REPO_NAME[1024] = "git@github.com:zeroc0d3/ruby-deploy-gcc.git";
    char REPO_BRANCH[64] = "master";
    
    // Shared Folders
    char *LIST_SHARED_FOLDERS[] = {
        "log",
        "tmp/cache",
        "tmp/pids",
        "tmp/sessions",
        "tmp/sockets",
        "vendor/assets",
        "public/assets",
        NULL
    };
    
    // Shared Files
    char *LIST_SHARED_FILES[] = {
        ".env",
        "faye.ru",
        "config.ru",
        "config/application.yml",
        "config/database.yml",
        "config/mongoid.yml",
        "config/pushr-staging.yml",
        "config/pushr-production.yml",
        "config/secrets.yml",
        "config/sidekiq.yml",
        "config/puma/staging.rb",
        "config/puma/production.rb",
        "config/unicorn/staging.rb",
        "config/unicorn/production.rb",
        NULL
    };
    

Environment Configuration

  • Development / Staging
    /* ======================================= 
          ENVIRONMENT CONFIGURATION 
       ======================================= */
    // DEVELOPMENT CONFIGURATION //
    // Development Environment
    char DEV_APP_ROOT[512]        = "/home/deploy/zeroc0d3lab.dev";                       // Development Root Path
    char DEV_CONFIG_FAYE[512]     = "/home/deploy/zeroc0d3lab.dev/current/faye.ru";                        // Development Faye Config
    char DEV_CONFIG_PUSHR[512]    = "/home/deploy/zeroc0d3lab.dev/current/config/pushr-staging.yaml";      // Development Pushr Config
    char DEV_CONFIG_SIDEKIQ[512]  = "/home/deploy/zeroc0d3lab.dev/current/config/sidekiq.yml";             // Development Sidekiq Config
    char DEV_CONFIG_UNICORN[512]  = "/home/deploy/zeroc0d3lab.dev/current/config/unicorn/staging.rb";      // Development Unicorn Config
    char DEV_CONFIG_PUMA[512]     = "/home/deploy/zeroc0d3lab.dev/current/config/puma/staging.rb";         // Development Puma Config
    char DEV_CONFIG_RU[512]       = "/home/deploy/zeroc0d3lab.dev/current/config/config.ru";               // Development config.ru Config
    
    char DEV_PID_FAYE[512]        = "/home/deploy/zeroc0d3lab.dev/current/tmp/pids/faye.pid";              // Development Path PID Faye
    char DEV_PID_PUSHR[512]       = "/home/deploy/zeroc0d3lab.dev/current/tmp/pids/pushr.pid";             // Development Path PID Pushr
    char DEV_PID_SIDEKIQ[512]     = "/home/deploy/zeroc0d3lab.dev/current/tmp/pids/sidekiq.pid";           // Development Path PID Sidekiq
    char DEV_PID_UNICORN[512]     = "/home/deploy/zeroc0d3lab.dev/current/tmp/pids/unicorn.pid";           // Development Path PID Unicorn
    char DEV_PID_PUMA[512]        = "/home/deploy/zeroc0d3lab.dev/current/tmp/pids/puma.pid";              // Development Path PID Puma
    char DEV_PID_STATE_PUMA[512]  = "/home/deploy/zeroc0d3lab.dev/current/tmp/pids/puma.state";            // Development Path PID State Puma
    
    char DEV_LOG_ENV[512]         = "/home/deploy/zeroc0d3lab.dev/current/log/staging.log";                // Development Path Log Environment
    char DEV_LOG_PUSHR[512]       = "/home/deploy/zeroc0d3lab.dev/current/log/pushr.log";                  // Development Path Log Pushr
    char DEV_LOG_SIDEKIQ[512]     = "/home/deploy/zeroc0d3lab.dev/current/log/sidekiq.log";                // Development Path Log Sidekiq
    char DEV_LOG_UNICORN[512]     = "/home/deploy/zeroc0d3lab.dev/current/log/unicorn.log";                // Development Path Log Unicorn
    char DEV_LOG_PUMA[512]        = "/home/deploy/zeroc0d3lab.dev/current/log/puma.log";                   // Development Path Log Puma
    
    char DEV_PATH_BUNDLE[512]     = "/home/zeroc0d3/.rbenv/shims/bundle";                   // Development Path of Bundle Binary
    char DEV_PATH_GEM[512]        = "/home/zeroc0d3/.rbenv/shims/gem";                      // Development Path of Gem Binary
    char DEV_PATH_RACKUP[512]     = "/home/zeroc0d3/.rbenv/shims/rackup";                   // Development Path of Rackup Binary
    // >= Rails v5.0
    char DEV_PATH_RAILS[512]      = "/home/zeroc0d3/.rbenv/shims/rails";                    // Development Path of Rails Binary
    // < Rails v5.0
    char DEV_PATH_RAKE[512]       = "/home/zeroc0d3/.rbenv/shims/rake";                     // Development Path of Rake Binary
    char DEV_PATH_PUSHR[512]      = "/home/zeroc0d3/.rbenv/shims/pushr";                    // Development Path of Pushr Binary
    char DEV_PATH_SIDEKIQ[512]    = "/home/zeroc0d3/.rbenv/shims/sidekiq";                  // Development Path of Sidekiq Binary
    char DEV_PATH_UNICORN[512]    = "/home/zeroc0d3/.rbenv/shims/unicorn";                  // Development Path of Unicorn Binary
    char DEV_PATH_PUMA[512]       = "/home/zeroc0d3/.rbenv/shims/puma";                     // Development Path of Puma Binary
    
  • Production
    /* ======================================= 
          ENVIRONMENT CONFIGURATION 
       ======================================= */
    // PRODUCTION CONFIGURATION //
    // Production Environment
    char PROD_APP_ROOT[512]       = "/home/deploy/zeroc0d3lab";                               // Production Root Path
    char PROD_CONFIG_FAYE[512]    = "/home/deploy/zeroc0d3lab/current/faye.ru";               // Production Faye Config
    char PROD_CONFIG_PUSHR[512]   = "/home/deploy/zeroc0d3lab/current/config/pushr-production.yaml";  // Production Pushr Config
    char PROD_CONFIG_SIDEKIQ[512] = "/home/deploy/zeroc0d3lab/current/config/sidekiq.yml";            // Production Sidekiq Config
    char PROD_CONFIG_UNICORN[512] = "/home/deploy/zeroc0d3lab/current/config/unicorn/production.rb";  // Production Unicorn Config
    char PROD_CONFIG_PUMA[512]    = "/home/deploy/zeroc0d3lab/current/config/puma/production.rb";     // Production Puma Config
    char PROD_CONFIG_RU[512]      = "/home/deploy/zeroc0d3lab/current/config/config.ru";               // Production config.ru Config
    
    char PROD_PID_FAYE[512]       = "/home/deploy/zeroc0d3lab/current/tmp/pids/faye.pid";             // Production Path PID Faye
    char PROD_PID_PUSHR[512]      = "/home/deploy/zeroc0d3lab/current/tmp/pids/pushr.pid";            // Production Path PID Pushr
    char PROD_PID_SIDEKIQ[512]    = "/home/deploy/zeroc0d3lab/current/tmp/pids/sidekiq.pid";          // Production Path PID Sidekiq
    char PROD_PID_UNICORN[512]    = "/home/deploy/zeroc0d3lab/current/tmp/pids/unicorn.pid";          // Production Path PID Unicorn
    char PROD_PID_PUMA[512]       = "/home/deploy/zeroc0d3lab/current/tmp/pids/puma.pid";             // Production Path PID Puma
    char PROD_PID_STATE_PUMA[512] = "/home/deploy/zeroc0d3lab/current/tmp/pids/puma.state";           // Production Path PID State Puma
    
    char PROD_LOG_ENV[512]        = "/home/deploy/zeroc0d3lab/current/log/production.log";            // Production Path Log Environment
    char PROD_LOG_PUSHR[512]      = "/home/deploy/zeroc0d3lab/current/log/pushr.log";                 // Production Path Log Pushr
    char PROD_LOG_SIDEKIQ[512]    = "/home/deploy/zeroc0d3lab/current/log/sidekiq.log";               // Production Path Log Sidekiq
    char PROD_LOG_UNICORN[512]    = "/home/deploy/zeroc0d3lab/current/log/unicorn.log";               // Production Path Log Unicorn
    char PROD_LOG_PUMA[512]       = "/home/deploy/zeroc0d3lab/current/log/puma.log";                  // Production Path Log Unicorn
    
    char PROD_PATH_BUNDLE[512]    = "/home/deploy/.rbenv/shims/bundle";           // Production Path of Bundle Binary
    char PROD_PATH_GEM[512]       = "/home/deploy/.rbenv/shims/gem";              // Production Path of Gem Binary
    char PROD_PATH_RACKUP[512]    = "/home/deploy/.rbenv/shims/rackup";           // Production Path of Rackup Binary
    // >= Rails v5.0
    char PROD_PATH_RAILS[512]     = "/home/deploy/.rbenv/shims/rails";            // Production Path of Rails Binary
    // < Rails v5.0
    char PROD_PATH_RAKE[512]      = "/home/deploy/.rbenv/shims/rake";             // Production Path of Rake Binary
    char PROD_PATH_PUSHR[512]     = "/home/deploy/.rbenv/shims/pushr";            // Production Path of Pushr Binary
    char PROD_PATH_SIDEKIQ[512]   = "/home/deploy/.rbenv/shims/sidekiq";          // Production Path of Sidekiq Binary
    char PROD_PATH_UNICORN[512]   = "/home/deploy/.rbenv/shims/unicorn";          // Production Path of Unicorn Binary
    char PROD_PATH_PUMA[512]      = "/home/deploy/.rbenv/shims/puma";             // Production Path of Puma Binary
    
    

Step Deploy for Development / Staging

  1. SSH username to VPS Staging
    ssh [username]@[vps_staging_ip]
    
  2. On folder /home/zeroc0d3
    cd /home/zeroc0d3
    
  3. Clone this repository as zeroc0d3-deploy
    cd /home/zeroc0d3
    git clone git@github.com:zeroc0d3/ruby-deploy-gcc.git zeroc0d3-deploy
    
  4. Checkout to branch master
  5. Configure file rb_deploy.c
  6. Setup section user-configuration for staging
  7. Setup section environment-configuration for staging
  8. Configure make-rb_deploy
  9. Make Binary
  10. Running Deployment for Develop / Staging

Step Deploy for Production

  1. SSH username to VPS Production
    ssh [username]@[vps_production_ip]
    
  2. On folder /home/deploy
    cd /home/deploy
    
  3. Clone this repository as staging
    cd /home/deploy
    git clone git@github.com:zeroc0d3/ruby-deploy-gcc.git rb_deploy
    
  4. Checkout to branch master
  5. Configure file rb_deploy.c
  6. Setup section user-configuration for production
  7. Setup section environment-configuration for production
  8. Configure make-rb_deploy
  9. Make Binary
  10. Running Deployment for Production

Configure make-rb_deploy

#!/usr/bin/env sh

PATH_PWD=`pwd` 
cd $PATH_PWD
gcc -o rb_deploy rb_deploy.c

# ======================= #
#   Setup for All Users   #
# ======================= #
PATH_LINK="/usr/local/bin/rb_deploy"
# A) Using Compile  
# sudo gcc -o $PATH_LINK rb_deploy.c 

# B) Using Symlink  
if ! [ -f "$PATH_LINK" ]
then
  sudo ln -s $PATH_PWD/rb_deploy /usr/local/bin/rb_deploy
  sudo ln -s /usr/local/bin/rb_deploy /bin/rb_deploy
fi

Make Binary

  • Build your binary deploy
./make-rb_deploy

Running Deployment

  • Type command:
./rb_deploy -dep        ## or
./rb_deploy -deploy     ## or
rb_deploy               ## (after global setup access with sudo)  

NOTES

  • DO NOT REMOVE NULL in shared folder/files lists.
  • If you're using rvm (Ruby Version Manager), change all:
    /home/deploy/.rbenv/shims
    
    to:
    /usr/local/rvm/gems/ruby-[version]/bin
    
Clone this wiki locally