Home>

Run Capistorano for new servers

/usr /bin /env git archive API | TAR -X -C /VAR /WWW /API /Releases /20210519123116 -strip= 1
Fail in

part

probably like you're trying to archive the previously deployed content
What is bad to run though it is the first time?

ARCHIVE API

I think that there are two spaces between

, so I think there is a revision name or something last time.
Because there is no
git stderr: fatal: not a Valid Object Name: API
It will become

CAPFILE

# load dsl and set up stages
Require 'Capistrano /SETUP'
# Include Default Deployment Tasks
Require 'Capistrano /DEPLOY'
# Include Tasks from Other Gems Included in Your Gemfile
#
# For Documentation on these, see forexample:
#
# Https://github.com/capistrano/RVM
# Https://github.com/capistrano/Rbenv
# Https://github.com/capistrano/chruby
# Https://github.com/capistrano/bundler
# Https://github.com/capistrano/rails
# Https://github.com/capistrano/passenger
#
# Require 'Capistrano /RVM'
# Require 'Capistrano /Rbenv'
# Require 'Capistrano /Chruby'
REQUIRE 'CAPISTRANO /BUNDLER'
Require 'Capistrano /Rails /Assets'
REQUIRE 'CAPISTRANO /RAILS /MIGRATIONS'
REQUIRE 'CAPISTRANO /RAILS'
Require 'Capistrano /Rails /DB'
# Require 'Capistrano /Passenger'
Require 'Capistrano3 /Unicorn'
Require 'Capistrano /Git'
Require "Whenever /Capistrano"
Class Capistrano :: Git
  Module subdirectorystrategy
    include DefaultStrategy
    DEF RELEASE
      git: archive, fetch (: branch), fetch (: project_root), '| tar -x -c', release_path, "--strip= # {fetch (: Project_root) .count ('/') + 1}"
    END
  END
END
# Load Custom Tasks from `lib /Capistrano /Tasks` IF You Have Any Defined
Dir.glob ('lib /Capistrano /Tasks /*. Rake'). Each {| R | Import R}
Require 'Capistrano /Delayed_Job'

deploy.rb

# config Valid for Current Version and Patch Releases of Capistrano
LOCK '3.4.1'
SET: Application, 'API'
SET: REPO_URL, 'ssh: //xxxxx.git'
# DEFAULT BRANCH IS: MASTER
# Ask: Branch, `git rev-parse --abbrev-ref Head`.chomp
SET: Branch, Env ['Branch'] || "MASTER"
# DEFAULT DEPLOY_TO DIRECTORY IS /VAR /WWW /my_App_Name
# SET: DEPLOY_TO, '/VAR /WWW /MY_APP_NAME
SET: DEPLOY_TO, '/VAR /WWW /API'
# Set: deploy_via: remote_cache
SET: Git_StRategy, Capistrano :: Git :: SubdirectoryStrategy
SET: PROJECT_ROOT, 'API'
# DEFAULT VALUE FOR: SCM Is: Git
SET: SCM: Git
# DEFAULT VALUE FOR: Format Is: Pretty
# Set: Format: Pretty
# Default value for: log_level is: Debug
SET: LOG_LEVEL,: Debug
# DEFAULT VALUE FOR: PTY is false
# Set: pty, true
# DEFAULT VALUE for: Linked_Files is []
# Set: linked_files, fetch (: linked_files, []). Push ('config /database.yml', 'config /secrets.yml')
# Set: linked_files, fetch (: linked_files, []). Push ('config /secrets.yml')
# SET: Linked_Files, FETCH (: Linked_Files, []). Push ('config /Master.key')
# DEFAULT VALUE FOR LINKED_DIRS IS []
SET: Linked_Dirs, FETCH (: Linked_Dirs, []). Push ('log', 'tmp /pids', 'tmp /cache', 'tmp /sockets', 'vendor /bundle', 'public /system')
# Set: linked_dirs (FETCH (: Linked_Dirs) + ['TMP'])
# DEFAULT VALUE FOR DEFAULT_ENV IS {}
# Set: default_env, {path: "/opt /ruby ​​/bin: $ Path"}
SET: DEFAULT_ENV, {
  rbenv_root: "/usr /local /rbenv",
  path: "/usr/local/rbenv/shims:/usr/local/rbenv/bin:/home/ec2-user/.rbenv/versions/2.5.1/bin :$path"
}
# DEFAULT VALUE FOR KEEP_RELEASES IS 5
SET: KEEP_RELEASES, 5
set: unicorn_rack_env, "none"
SET: Unicorn_Config_Path, 'config /Unicorn.rb'
# Set: whenever_command, "Bundle Exec WHENEVER"
SET: WHENEVER_IDENTIFIER->
{"# {FETCH (: Application)} _ # {FETCH (: STAGE)}"} "
# SET: WHENEVER_IDENTIFIER->
{"# {FETCH (: Application)} _ # {Fetch (: Development)}"} "
# SET: WHENEVER_ROLES,: BATCH
# Set: WHENEVER_ENVIRONMENT: Development
# SET: WHENEVER_ROLES, ->
{: db}
# SET: WHENEVER_COMMAND->
{[: Bundle,: Exec,: Whenever]}
# SET: WHENEVER_COMMAND_ENVIRONMENT_VARIABLES, ->{{}} # Set: WHENEVER_IDENTIFIER, ->
{Fetch: Application}
# SET: WHENEVER_ENVIRONMENT->
{Fetch: Rails_env, Fetch (: Stage, "Development")}
# SET: WHENEVER_VARIABLES,->
{"Environment= # {Fetch: WHENEVER_ENVIRONMENT}"
# SET: WHENEVER_UPDATE_FLAGS->
{"--update-crontab # {fetch: whenever_identifier} --set # {Fetch: whenever_variables}"} "
# SET: WHENEVER_CLEAR_FLAGS->
{"--clear-crontab # {Fetch: whenever_identifier}"
Sshkit.config.command_map [: rake]= 'Bundle Exec Rake'
After 'Deploy: Publishing', 'Deploy: Restart'
Namespace: Deploy Do
  Task: db_seed do
     ON ROLES (: DB) Do | HOST |
       WITHIN CURRENT_PATH DO
         with rails_env: fetch (: Rails_env) Do
           Execute: Rake, 'DB: SEED_FU'
         END
       END
     END
  END
  Task: START DO
    Invoke 'Unicorn: START'
  END
  Task: Restart DO
    Invoke 'Unicorn: Restart'
  END
  Task: STOP DO
    Invoke 'Unicorn: STOP'
  END
  DESC "DUMP THE DATA TO DB /data.yml"
  task: dump_data_yml do
    ON ROLES (: DB) Do | HOST |
      WITHIN CURRENT_PATH DO
        with rails_env: fetch (: Rails_env) Do
          Execute: Rake, 'DB: Data: DUMP'
        END
      END
    END
  END
  DESC "Load The Seed Data from db /data.yml"
  task: Load_Data_YML DO
    ON ROLES (: DB) Do | HOST |
      WITHIN CURRENT_PATH DO
        with rails_env: fetch (: Rails_env) Do
          Execute: Rake, 'db: Load'
        END
      END
    END
  END
# After: restart,: clear_cache do
# On Roles (: web), in :: Groups, Limit: 3, WAIT: 10 DO
      # Here We Can Do Anything Such AS:
      # Within release_path do
      # Execute: Rake, 'Cache: Clear'
      # END
# END
# END
END

May I add CAPFILE or CONFIG /deploy.rb content?

Masafumi Okura2021-09-15 22:13:05

I added. Thank you

KTI2021-09-15 22:13:05

The process was also written in a file called Capfile ... It seems that it has become a brunch with an environment variable and has been self-solved! Thank you for the information!

KTI2021-09-15 22:13:05
  • Answer # 1

    In CapFile

    Git: Archive, Fetch (: Branch), Fetch (: Project_root), '| Tar -x -c', Release_Path, "--strip= # {Fetch (: Project_root) .count ('/') +1} "
    
    There is
    
    SET: Branch, Env ['Branch' || "MASTER"
    
    

    It seems that the branch name was made from the environment variable here
    When the branch was set to the environment variable, the error in this part has disappeared