Capistrano Passenger 使用教程
passengerPassenger support for Capistrano 3.x项目地址:https://gitcode.com/gh_mirrors/pas/passenger
1. 项目的目录结构及介绍
Capistrano Passenger 项目的目录结构如下:
capistrano-passenger/
├── Gemfile
├── Gemfile.lock
├── LICENSE.md
├── README.md
├── Rakefile
├── lib/
│ ├── capistrano/
│ │ ├── passenger.rb
│ │ └── tasks/
│ │ └── passenger.rake
│ └── capistrano.rb
└── spec/
├── passenger_spec.rb
└── spec_helper.rb
目录结构介绍
Gemfile
和Gemfile.lock
:定义了项目的依赖关系。LICENSE.md
:项目的许可证信息。README.md
:项目的说明文档。Rakefile
:用于定义 Rake 任务。lib/
:包含项目的主要代码。capistrano/
:Capistrano 相关的代码。passenger.rb
:Passenger 的主要配置文件。tasks/
:包含 Passenger 相关的 Rake 任务。
capistrano.rb
:Capistrano 的初始化文件。
spec/
:包含项目的测试代码。
2. 项目的启动文件介绍
项目的启动文件主要是 lib/capistrano/passenger.rb
。这个文件定义了 Passenger 的主要配置和行为。
lib/capistrano/passenger.rb
文件介绍
require "capistrano/bundler"
require "capistrano/passenger/monit"
namespace :passenger do
desc "Restart application"
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :touch, release_path.join("tmp/restart.txt")
end
end
after "deploy:publishing", "passenger:restart"
end
require "capistrano/bundler"
:引入 Capistrano 的 Bundler 插件。require "capistrano/passenger/monit"
:引入 Passenger 的 Monit 插件。namespace :passenger
:定义 Passenger 命名空间。task :restart
:定义重启任务。after "deploy:publishing", "passenger:restart"
:在发布后执行重启任务。
3. 项目的配置文件介绍
项目的配置文件主要是 config/deploy.rb
和 config/deploy/production.rb
(或其他环境配置文件)。
config/deploy.rb
文件介绍
# config valid for current version and patch releases of Capistrano
lock "~> 3.16.0"
set :application, "my_app_name"
set :repo_url, "git@example.com:me/my_repo.git"
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app_name
# set :deploy_to, "/var/www/my_app_name"
# Default value for :format is :airbrussh.
# set :format, :airbrussh
# You can configure the Airbrussh format using :format_options.
# These are the defaults.
# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
# append :linked_files, "config/database.yml", "config/secrets.yml"
# Default value for linked_dirs is []
# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system"
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for local_user is ENV['USER']
# set :local_user, -> { `git config user.name`.chomp }
# Default value for keep_releases is 5
# set :keep_releases
passengerPassenger support for Capistrano 3.x项目地址:https://gitcode.com/gh_mirrors/pas/passenger