Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change settings to deploy on vps #62

Merged
merged 1 commit into from
Aug 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .buildpacks

This file was deleted.

17 changes: 4 additions & 13 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ gem 'tinymce-rails-langs' # tinymce language pack
gem "jquery-fileupload-rails" # jquery-fielupload plugin
gem 'jquery-ui-rails' # jqueryUI
gem 'ejs' # js templating for js test fixtures
gem 'meppit-map-rails', :github => 'it3s/meppit-map-rails' # our beloved map
gem 'meppit-map-rails', github: 'it3s/meppit-map-rails' # our beloved map

# gem 'turbolinks' # speed page loading

Expand All @@ -38,19 +38,20 @@ gem 'http_accept_language' # get locale from http headers
gem 'carrierwave' # file uploads abstraction
gem 'carrierwave_backgrounder' # delegate uploads to background jobs
gem 'mini_magick' # image processing for uploaders
gem 'fog' # upload images to amazon S3
gem 'remotipart' # enable ajax file uploads on remote forms
gem 'kaminari' # paginator
gem 'event_bus' # event bus for decoupling logic between models
gem 'rdiscount' # render markdown
gem 'paper_trail' # model versioning
gem 'differ' # build diffs
gem 'safe_yaml', require: false # safe yaml loading


gem 'better_errors' # better error page, and shell session when crash
gem 'binding_of_caller' # used by better_errors

group :doc do
gem 'sdoc', :require => false
gem 'sdoc', require: false
end

group :development do
Expand Down Expand Up @@ -81,15 +82,5 @@ group :test do
end

group :production, :staging do
gem 'rails_12factor' # heroku rails logs and assets
gem 'mailgun_rails' # mailgun integration for actionmailer
end

# Rails requires automatically all gems from the default and environment groups
# This group allows the gem to be available but not required, so we can load
# it manually
# for example: we need to import safe_yaml with 'safe_yaml/load' so it don't
# patch the default YAML, which would break sidekiq and other libs
group :do_not_autoload do
gem 'safe_yaml' # safe yaml loading
end
30 changes: 0 additions & 30 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ GEM
ejs (1.1.1)
erubis (2.7.0)
event_bus (1.0.0)
excon (0.37.0)
execjs (2.2.0)
factory_girl (4.4.0)
activesupport (>= 3.0.0)
Expand All @@ -124,24 +123,6 @@ GEM
figaro (0.7.0)
bundler (~> 1.0)
rails (>= 3, < 5)
fog (1.22.1)
fog-brightbox
fog-core (~> 1.22)
fog-json
ipaddress (~> 0.5)
nokogiri (~> 1.5, >= 1.5.11)
fog-brightbox (0.0.2)
fog-core
fog-json
fog-core (1.22.0)
builder
excon (~> 0.33)
formatador (~> 0.2)
mime-types
net-scp (~> 1.1)
net-ssh (>= 2.1.3)
fog-json (1.0.0)
multi_json (~> 1.0)
font-awesome-sass (4.1.0)
sass (~> 3.2)
foreman (0.71.0)
Expand Down Expand Up @@ -170,7 +151,6 @@ GEM
slop (>= 3.5.0)
term-ansicolor
terminal-table
ipaddress (0.8.0)
jquery-fileupload-rails (0.4.1)
actionpack (>= 3.1)
railties (>= 3.1)
Expand Down Expand Up @@ -220,9 +200,6 @@ GEM
neat (1.5.1)
bourbon (>= 3.1)
sass (~> 3.2.19)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.1)
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
oauth (0.4.7)
Expand Down Expand Up @@ -269,11 +246,6 @@ GEM
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.1)
sprockets-rails (~> 2.0)
rails_12factor (0.0.2)
rails_serve_static_assets
rails_stdout_logging
rails_serve_static_assets (0.0.2)
rails_stdout_logging (0.0.3)
railties (4.1.1)
actionpack (= 4.1.1)
activesupport (= 4.1.1)
Expand Down Expand Up @@ -407,7 +379,6 @@ DEPENDENCIES
event_bus
factory_girl_rails
figaro
fog
font-awesome-sass
foreman
guard-rspec
Expand All @@ -433,7 +404,6 @@ DEPENDENCIES
pry-rails
puma
rails (~> 4.1.1)
rails_12factor
rdiscount
remotipart
rgeo
Expand Down
6 changes: 1 addition & 5 deletions app/uploaders/avatar_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick

# Choose what kind of storage to use for this uploader:
if Rails.env.test? or Rails.env.development?
storage :file
else
storage :fog
end
storage :file

# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
Expand Down
22 changes: 0 additions & 22 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,6 @@
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)

class ActiveRecordOverrideRailtie < Rails::Railtie
initializer "active_record.initialize_database.override" do |app|

ActiveSupport.on_load(:active_record) do
if url = ENV['DATABASE_URL']
ActiveRecord::Base.connection_pool.disconnect!
parsed_url = URI.parse(url)
config = {
adapter: 'postgis',
host: parsed_url.host,
encoding: 'unicode',
database: parsed_url.path.split("/")[-1],
port: parsed_url.port,
username: parsed_url.user,
password: parsed_url.password
}
establish_connection(config)
end
end
end
end

module Meppit
class Application < Rails::Application
# Set Time.zone default and make Active Record auto-convert to this zone.
Expand Down
22 changes: 6 additions & 16 deletions config/application.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ development:
FACEBOOK_SECRET: ""
GOOGLE_KEY: ""
GOOGLE_SERCRET: ""
S3_KEY: ""
S3_SECRET: ""
S3_BUCKET: ""

test:
FIXED_SALT: "test-salt"
Expand All @@ -19,9 +16,6 @@ test:
FACEBOOK_SECRET: ""
GOOGLE_KEY: ""
GOOGLE_SECRET: ""
S3_KEY: ""
S3_SECRET: ""
S3_BUCKET: ""

staging:
SECRET_TOKEN: ""
Expand All @@ -30,14 +24,12 @@ staging:
FACEBOOK_SECRET: ""
GOOGLE_KEY: ""
GOOGLE_SECRET: ""
S3_KEY: ""
S3_SECRET: ""
S3_BUCKET: ""
MAILGUN_API_KEY: ""
MAILGUN_DOMAIN: ""
MEPPIT_HOST: ""
MIN_THREADS: 1
MAX_THREADS: 1
DB_USERNAME: ""
DB_PASSWORD: ""


production:
SECRET_TOKEN: ""
Expand All @@ -46,11 +38,9 @@ production:
FACEBOOK_SECRET: ""
GOOGLE_KEY: ""
GOOGLE_SECRET: ""
S3_KEY: ""
S3_SECRET: ""
S3_BUCKET: ""
MAILGUN_API_KEY: ""
MAILGUN_DOMAIN: ""
MEPPIT_HOST: ""
MIN_THREADS: 1
MAX_THREADS: 1
DB_USERNAME: ""
DB_PASSWORD: ""

19 changes: 4 additions & 15 deletions config/initializers/carrierwave.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
if Rails.env.test? || Rails.env.development?
CarrierWave.configure do |config|
config.storage = :file
config.enable_processing = false
end
else
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => ENV.fetch("S3_KEY", ""),
:aws_secret_access_key => ENV.fetch("S3_SECRET", ""),
}
config.asset_host = "https://s3.amazonaws.com/#{ENV["S3_BUCKET"]}"
config.fog_directory = ENV["S3_BUCKET"]
end
CarrierWave.configure do |config|
config.storage = :file
config.enable_processing = false
end

15 changes: 0 additions & 15 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
ENV["REDISTOGO_URL"] ||= "redis://localhost:6379"

Sidekiq.configure_server do |config|
config.redis = { url: ENV["REDISTOGO_URL"] }

database_url = ENV['DATABASE_URL']
if database_url
ENV['DATABASE_URL'] = "#{database_url}?pool=10"
ActiveRecord::Base.establish_connection
end

end


Sidekiq.configure_client do |config|
config.redis = { url: ENV["REDISTOGO_URL"] }
config.logger.level = Logger::WARN
end
5 changes: 2 additions & 3 deletions config/sidekiq.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
:verbose: false
:pidfile: ./tmp/pids/sidekiq.pid
# Set timeout to 8 on Heroku, longer if you manage your own systems.
:timeout: 8
:timeout: 20
:queues:
- [default, 1]
- [mailer, 1]
- [uploads, 1]
staging:
:concurrency: 2
:concurrency: 25
production:
:concurrency: 25
development:
Expand Down