Nginx 执行 cap production deploy 后,nginx.access.log 出现 puma.sock 报错

sec · 2017年04月12日 · 6805 次阅读

服务器没有生成 apps/xxx/shared/tmp/sockets/xxx-puma.sock 文件。 /tmp/sockets文件夹为空?请问如何创建 /tmp/sockets/puma.sock 文件

nginx.access.log 错误日志

2017/04/12 16:17:36 [crit] 25088#25088: *12 connect() to unix:///home/deploy/apps/xxx/shared/tmp/sockets/xxx-puma.sock failed (2: No such file or directory) while connecting to upstream, client: 103.250.xxx.xxx, server: xxx
deploy.rb

server '106.14.xxx.xx', roles: [:web, :app, :db], primary: true
set :application, "ror"
set :repo_url,        'ssh://[email protected]:/home/git/repositories/ror.git'
set :application,     'xxx'
set :user,            'deploy'
# set :branch, 'master'(默认为master)
set :puma_threads,    [4, 16]
set :puma_workers,    1

# Don't change these unless you know what you're doing
set :pty,             true
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 :ssh_options,     {user: fetch(:user)}

set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true  # Change to false when not using ActiveRecord

before "deploy:migrate",     "db:default"
after  "deploy:finishing",    :compile_assets
after  "deploy:finishing",    :cleanup

namespace :db do
  desc 'Create database yml in shared_path'
  task :default do
    on roles(:web) do
      puts "start generate database.yml xxxxxxxxx"
      db_config = ERB.new <<-EOF
        base: &base
          host: localhost
          adapter: mysql2
          encoding: utf8
          reconnect: false
          pool: 5
          username: #{fetch(:user)}
          password: xxxx

        development:
          database: #{fetch(:application)}_dev
          <<: *base
        test:
          database: #{fetch(:application)}_test
          <<: *base

        production:
          database: #{fetch(:application)}_prod
          <<: *base

      EOF

      p (a = db_config.result.gsub("\n","\\n"))
      execute "mkdir -p #{shared_path}/config"
      execute "touch /home/deploy/apps/ror/shared/config/database_tmp.yml"
      execute "echo  -e '#{a}' >> #{shared_path}/config/database_tmp.yml"
      execute "mv #{shared_path}/config/database_tmp.yml #{shared_path}/config/database.yml"
      execute "cp #{shared_path}/config/database.yml  #{release_path}/config/database.yml"

      execute "cat #{shared_path}/config/database.yml"
      puts "generate database.yml successfully"
    end
  end

  desc "Make symlink for database yml"
  task :symlink do
    on roles(:web) do
      puts "enter in symlink"
      execute "ln -fs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
    end
  end
end

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

  before :start, :make_dirs
end


sec 关闭了讨论。 04月19日 15:01
需要 登录 后方可回复, 如果你还没有账号请 注册新账号