部署 无法启动 puma

gwq · March 22, 2017 · Last by gwq replied at March 22, 2017 · 2734 hits

当执行 bundle exec cap production puma:start 这行命令时出现


bundle: command not found

Gemfile 和 Capfile 里面都配置了 bundler ,服务器端也安装了 bundler,我没有再谷歌找到相应的答案。

错误信息不够详细,截图不够详细

最好能贴相关代码

先检查一下服务器环境吧,我猜是 sshkit 所加载的 bash 环境与你预期的不一样

贴一下我项目里相关的配置:

deploy.rb

set :bundle_bins, %w(gem rake rails sidekiq sidekiqctl)

set :puma_rackup, -> { File.join(current_path, 'config.ru') }
set :puma_state, -> { "#{shared_path}/tmp/pids/puma.state" }
set :puma_pid, -> { "#{shared_path}/tmp/pids/puma.pid" }
set :puma_bind, -> { "unix://#{shared_path}/tmp/sockets/puma.sock" }
set :puma_conf, -> { "#{shared_path}/puma.rb" }
set :puma_access_log, -> { "#{shared_path}/log/puma.log" }
set :puma_error_log, -> { "#{shared_path}/log/puma.err.log" }
set :puma_role, :app
set :puma_env, -> { fetch(:rack_env, fetch(:rails_env, 'production')) }
set :puma_threads, [4, 16]
set :puma_workers, 4
set :puma_worker_timeout, 30
set :puma_init_active_record, true
set :puma_preload_app, true
set :puma_prune_bundler, true

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

Capfile

require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/scm/git'
install_plugin Capistrano::SCM::Git

# Plugins
require 'capistrano/safe_deploy_to'
require 'capistrano/puma'
require 'capistrano/puma/nginx'
require 'capistrano/faster_assets'
require 'capistrano/sidekiq'
require 'sshkit/sudo'

你可以对照检查一下

rbenv 的话: set :rbenv_map_bins, %w{rake gem bundle ruby rails puma pumactl}

可以试试用 mina 配置还是比较方便的

mina+sidekiq+puma+rbenv

deploy.rb 是这样的

谢了各位,已解决

gwq closed this topic. 22 Mar 15:52
You need to Sign in before reply, if you don't have an account, please Sign up first.