0

我需要为我的 Rails 应用程序部署带有守护进程和 capistrano 的邮递员。我偶然发现了这篇文章,只是按照他写的步骤进行操作。

但是当我尝试部署它时,我的本地机器给了我这个错误:

The deploy has failed with an error: undefined local variable or method `mailman' 

我使用 capistrano 3.4.0。这是因为gem版本吗?

下面是我的config/deploy.config文件:

server '178.62.16.69', port: 22, roles: [:web, :app, :db], primary: true

set :repo_url,        'git@github.com:xxxxx/xxxxx.git'
set :application,     'xxxx'
set :user,            'deploy'
set :puma_threads,    [4, 16]
set :puma_workers,    0

set :pty,             false
set :use_sudo,        false
set :stage,           :production
set :deploy_via,      :remote_cache
set :deploy_to,       "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
set :puma_bind,       "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state,      "#{shared_path}/tmp/pids/puma.state"
set :puma_pid,        "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.error.log"
set :puma_error_log,  "#{release_path}/log/puma.access.log"
set :ssh_options,     { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true  # Change to false when not using ActiveRecord

set :whenever_identifier, ->{ "myapp_#{fetch(:stage)}" }

namespace :puma do
  desc 'Create Directories for Puma Pids and Socket'
  task :make_dirs do
    on roles(:app) do
      execute "mkdir #{shared_path}/tmp/sockets -p"
      execute "mkdir #{shared_path}/tmp/pids -p"
    end
  end

  before :start, :make_dirs
end

namespace :deploy do
  desc "Make sure local git is in sync with remote."
  task :check_revision do
    on roles(:app) do
      unless `git rev-parse HEAD` == `git rev-parse origin/master`
        puts "WARNING: HEAD is not the same as origin/master"
        puts "Run `git push` to sync changes."
        exit
      end
    end
  end

  desc 'Initial Deploy'
  task :initial do
    on roles(:app) do
      before 'deploy:restart', 'puma:start'
      invoke 'deploy'
    end
  end

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      invoke 'puma:restart'
    end
  end

  before :starting,     :check_revision
  after  :finishing,    :compile_assets
  after  :finishing,    :cleanup
  after  :finishing,    :restart

end

# Mailman configuration
namespace :mailman do
  desc "Mailman::Start"
  task :start, :roles => [:app] do
      run "cd #{current_path};RAILS_ENV=#{rails_env} script/mailman_daemon.rb start"
  end

  desc "Mailman::Stop" 
  task :stop, :roles => [:app] do
      run "cd #{current_path};RAILS_ENV=#{rails_env} script/mailman_daemon.rb stop"
  end 

  desc "Mailman::Restart" 
  task :restart, :roles => [:app] do
      mailman.stop mailman.start
  end
end 
before "deploy:cleanup", "mailman:restart"
4

0 回答 0