嗨我有一个试图在aws实例上部署的rails应用程序
这些是我的配置
配置/ deploy.rb
lock '3.5.0'
set :application, 'fullpower_tee'
set :repo_url, 'git_repo_url' # Edit this to match your repository
set :branch, :master
set :deploy_to, '/home/deploy2/fullpower_tee'
set :pty, true
set :linked_files, %w{config/database.yml config/application.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}
set :keep_releases, 5
set :rvm_type, :user
set :rvm_ruby_version, 'ruby-2.2.1'
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" #accept array for multi-bind
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_error.log"
set :puma_error_log, "#{shared_path}/log/puma_access.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
set :puma_threads, [0, 8]
set :puma_workers, 0
set :puma_worker_timeout, nil
set :puma_init_active_record, true
set :puma_preload_app, false
的Gemfile
gem 'figaro'
gem 'puma'
group :development do
gem 'capistrano'
gem 'capistrano3-puma'
gem 'capistrano-rails', require: false
gem 'capistrano-bundler', require: false
gem 'capistrano-rvm'
end
Capfile
# Load DSL and set up stages
require "capistrano/setup"
# Include default deployment tasks
require "capistrano/deploy"
require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/rails/assets' # for asset handling add
require 'capistrano/rails/migrations' # for running migrations
require 'capistrano/puma'
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
环境/ production.rb
Hadean::Application.configure do
# Rails 4
config.eager_load = true
config.assets.js_compressor = :uglifier
# Settings specified here will take precedence over those in config/environment.rb
config.force_ssl = true
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
# Generate digests for assets URLs
config.assets.digest = true
# config.assets.precompile += %w( *.css *.js )
# Add the fonts path
config.assets.paths << "#{Rails.root}/app/assets/fonts"
# Precompile additional assets
config.assets.precompile += %w( .svg .eot .woff .ttf )
config.assets.precompile += %w( *.js )
config.assets.precompile += [ 'admin.css',
'admin/app.css',
'admin/cart.css',
'admin/foundation.css',
'admin/normalize.css',
'admin/help.css',
'admin/ie.css',
'autocomplete.css',
'application.css',
'chosen.css',
'foundation.css',
'foundation_and_overrides.css',
'home_page.css',
'ie.css',
'ie6.css',
'login.css',
'markdown.css',
'myaccount.css',
'normalize.css',
'pikachoose_product.css',
'product_page.css',
'products_page.css',
'shopping_cart_page.css',
'signup.css',
'site/app.css',
'sprite.css',
'tables.css',
'cupertino/jquery-ui-1.8.12.custom.css',# in vendor
'modstyles.css', # in vendor
'scaffold.css' # in vendor
]
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# if ENV['FOG_DIRECTORY'].present?
# config.action_controller.asset_host = "//#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
# end
# Specifies the header that your server uses for sending files
config.action_dispatch.x_sendfile_header = "X-Sendfile"
# For nginx:
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
# If you have no front-end server that supports something like X-Sendfile,
# just comment this out and Rails will serve the files
config.cache_store = :memory_store
#config.cache_store = :dalli_store
# See everything in the log (default is :info)
# config.log_level = :debug
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Use a different cache store in production
# config.cache_store = :mem_cache_store
# Disable Rails's static asset server
# In production, Apache or nginx will already do this
config.serve_static_files = true
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => 'fullpowertee',
:access_key_id => 'AWS_KEY',
:secret_access_key => 'AWS_SECRET'
},
:s3_region => 'Oregon'
}
# Enable serving of images, stylesheets, and javascripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
config.action_mailer.default_url_options = { :host => 'ror-e.herokuapp.com' }
# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false
# Enable threaded mode
# config.threadsafe!
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
end
在AWS实例服务器上我有
的/ etc / nginx的/位点可用/默认
upstream app {
# Path to Puma SOCK file, as defined previously
server unix:/home/deploy2/fullpower_tee/shared/tmp/sockets/puma.sock fail_timeout=0;
}
server {
listen 80;
server_name localhost;
root /home/deploy2/fullpower_tee/current/public;
try_files $uri/index.html $uri @app;
location / {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Connection '';
proxy_pass http://app;
}
location ~ ^/(assets|fonts|system)/|favicon.ico|robots.txt {
gzip_static on;
expires max;
add_header Cache-Control public;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
我能够使用capistrano成功部署,并且我从capistrano获得服务器启动并运行的成功消息
我也可以从
看到/home/deploy2/fullpower_tee/shared/log/puma_error.log
* Inherited unix:///home/deploy2/fullpower_tee/shared/tmp/sockets/puma.sock
* Restarting...
Refreshing Gemfile
Puma starting in single mode...
* Version 3.4.0 (ruby 2.2.1-p85), codename: Owl Bowl Brawl
* Min threads: 0, max threads: 8
* Environment: production
* Daemonizing...
=== puma startup: 2016-06-12 08:44:07 +0000 ===
此外,我已经在部署
后完成了sudo服务nginx重启现在一切似乎都很好,但是当我尝试点击AWS实例的公共IP时,它会停止加载并且浏览器会抛出错误
This webpage is not available
ERR_CONNECTION_TIMED_OUT
请帮助我,因为我有一天坚持这个问题