trireme 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +1 -0
  7. data/bin/trireme +12 -0
  8. data/lib/trireme/actions.rb +20 -0
  9. data/lib/trireme/app_builder.rb +207 -0
  10. data/lib/trireme/generators/app_generator.rb +177 -0
  11. data/lib/trireme/templates/.rspec +1 -0
  12. data/lib/trireme/templates/Capfile +4 -0
  13. data/lib/trireme/templates/Guardfile +32 -0
  14. data/lib/trireme/templates/README.md.erb +6 -0
  15. data/lib/trireme/templates/additional_gems +37 -0
  16. data/lib/trireme/templates/app/assets/stylesheets/_bootstrap_and_overrides.scss +818 -0
  17. data/lib/trireme/templates/app/assets/stylesheets/application.css.scss +3 -0
  18. data/lib/trireme/templates/app/helpers/utility_helper.rb +32 -0
  19. data/lib/trireme/templates/app/views/layouts/application.html.erb +34 -0
  20. data/lib/trireme/templates/app/views/shared/_admin_actions.html.erb +3 -0
  21. data/lib/trireme/templates/app/views/shared/_flashes.html.erb +12 -0
  22. data/lib/trireme/templates/app/views/shared/_form_errors.html.erb +9 -0
  23. data/lib/trireme/templates/config/deploy/production.rb +17 -0
  24. data/lib/trireme/templates/config/deploy/staging.rb +8 -0
  25. data/lib/trireme/templates/config/deploy.rb.erb +41 -0
  26. data/lib/trireme/templates/config/environments/development.rb +45 -0
  27. data/lib/trireme/templates/config/environments/production.rb +70 -0
  28. data/lib/trireme/templates/config/environments/staging.rb +68 -0
  29. data/lib/trireme/templates/config/environments/test.rb +37 -0
  30. data/lib/trireme/templates/config/initializers/better_errors.rb +1 -0
  31. data/lib/trireme/templates/config/initializers/jazz_hands.rb +4 -0
  32. data/lib/trireme/templates/config/recipes/base.rb +8 -0
  33. data/lib/trireme/templates/config/recipes/check.rb +14 -0
  34. data/lib/trireme/templates/config/recipes/log.rb +6 -0
  35. data/lib/trireme/templates/config/recipes/logrotate.rb +8 -0
  36. data/lib/trireme/templates/config/recipes/nginx.rb +17 -0
  37. data/lib/trireme/templates/config/recipes/postgresql.rb +32 -0
  38. data/lib/trireme/templates/config/recipes/scripts/sql_functions.sql +23 -0
  39. data/lib/trireme/templates/config/recipes/templates/logrotate.erb +9 -0
  40. data/lib/trireme/templates/config/recipes/templates/nginx_unicorn.erb +69 -0
  41. data/lib/trireme/templates/config/recipes/templates/postgresql.yml.erb +8 -0
  42. data/lib/trireme/templates/config/recipes/templates/unicorn.rb.erb +14 -0
  43. data/lib/trireme/templates/config/recipes/templates/unicorn_init.erb +84 -0
  44. data/lib/trireme/templates/config/recipes/unicorn.rb +26 -0
  45. data/lib/trireme/templates/gitignore_additions +2 -0
  46. data/lib/trireme/templates/lib/templates/erb/scaffold/_form.html.erb +16 -0
  47. data/lib/trireme/templates/lib/templates/erb/scaffold/edit.html.erb +6 -0
  48. data/lib/trireme/templates/lib/templates/erb/scaffold/index.html.erb +27 -0
  49. data/lib/trireme/templates/lib/templates/erb/scaffold/new.html.erb +5 -0
  50. data/lib/trireme/templates/lib/templates/erb/scaffold/show.html.erb +10 -0
  51. data/lib/trireme/templates/spec/spec_helper.rb +60 -0
  52. data/lib/trireme/version.rb +3 -0
  53. data/lib/trireme.rb +48 -0
  54. data/trireme.gemspec +23 -0
  55. metadata +127 -0
@@ -0,0 +1,3 @@
1
+ @import "compass";
2
+ @import "bootstrap_and_overrides";
3
+ @import "font-awesome";
@@ -0,0 +1,32 @@
1
+ module UtilityHelper
2
+ def title(page_title)
3
+ content_for(:title) { page_title }
4
+ end
5
+
6
+ def icon(name, opts = {})
7
+ opts[:size] = opts[:size] == 1 ? 'lg' : opts[:size].to_s + 'x' if opts[:size]
8
+ name = name.to_s.gsub('_', '-')
9
+
10
+ html_tag = ""
11
+ html_tag << '<div class="icon-wrapper">' if opts[:wrapper]
12
+
13
+ if opts[:circle]
14
+ html_tag << "<span class=\"fa-stack fa-#{opts[:size] || 'lg'}\">"
15
+ html_tag << '<i class="fa fa-circle fa-stack-2x"></i>'
16
+ html_tag << "<i class=\"fa fa-#{name} fa-stack-1x fa-inverse\"></i>"
17
+ html_tag << '</span>'
18
+ else
19
+ html_tag << "<i class=\"fa fa-#{name}"
20
+ html_tag << " #{opts[:additional]}" if opts.has_key? :additional
21
+ html_tag << " fa-border" if opts[:border]
22
+ html_tag << " fa-#{opts[:size]}" if opts[:size]
23
+ html_tag << '"></i>'
24
+ html_tag << '</div>' if opts[:wrapper]
25
+ end
26
+ html_tag.html_safe
27
+ end
28
+
29
+ def placeholder(width, height = nil, text = nil)
30
+ [["http://placehold.it/#{width}", *height].join("x"), *text].join("&text=")
31
+ end
32
+ end
@@ -0,0 +1,34 @@
1
+ <!DOCTYPE html>
2
+ <!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
3
+ <!--[if lt IE 7 ]> <html class="ie6" lang="en"> <![endif]-->
4
+ <!--[if IE 7 ]> <html class="ie7" lang="en"> <![endif]-->
5
+ <!--[if IE 8 ]> <html class="ie8" lang="en"> <![endif]-->
6
+ <!--[if (gte IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
7
+ <head>
8
+ <meta charset="utf-8" />
9
+
10
+ <!-- Uncomment to make IE8 render like IE7 -->
11
+ <!-- <meta http-equiv="X-UA-Compatible" content="IE=7" /> -->
12
+
13
+ <!-- Set the viewport width to device width for mobile -->
14
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
15
+
16
+ <title><%= content_for?(:title) ? yield(:title) : "Base Title" %></title>
17
+
18
+ <!-- Include google fonts -->
19
+ <!-- <link href='http://fonts.googleapis.com/css?family=Family1|Family2' rel='stylesheet' type='text/css'> -->
20
+
21
+ <%= stylesheet_link_tag "application", media: "all" %>
22
+ <%= csrf_meta_tags %>
23
+ </head>
24
+
25
+ <body>
26
+
27
+ <div class="container">
28
+ <%= render 'shared/flashes' %>
29
+ <%= yield %>
30
+ </div>
31
+
32
+ <%= javascript_include_tag "application" %>
33
+ </body>
34
+ </html>
@@ -0,0 +1,3 @@
1
+ <%= link_to "#{icon :info}".html_safe, send("admin_#{obj.class.name.underscore}_path", obj), class: 'btn btn-primary' %>
2
+ <%= link_to "#{icon :edit}".html_safe, send("edit_admin_#{obj.class.name.underscore}_path", obj), class: 'btn btn-warning' %>
3
+ <%= link_to "#{icon :trash_o}".html_safe, send("admin_#{obj.class.name.underscore}_path", obj), method: :delete, data: { confirm: "Are you sure you want to delete the #{obj.class.name} '#{obj}'?" }, class: 'btn btn-danger' %>
@@ -0,0 +1,12 @@
1
+ <% if notice %>
2
+ <div class="alert-box" data-alert>
3
+ <%= notice %>
4
+ <a href="#" class="close">&times;</a>
5
+ </div>
6
+ <% end -%>
7
+ <% if alert %>
8
+ <div class="alert-box alert" data-alert>
9
+ <%= alert %>
10
+ <a href="#" class="close">&times;</a>
11
+ </div>
12
+ <% end -%>
@@ -0,0 +1,9 @@
1
+ <div class="alert alert-danger">
2
+ <p><%= pluralize(obj.errors.count, "error") %> prohibited this <%= obj.class.model_name.human %> from being saved:</p>
3
+
4
+ <ul>
5
+ <% obj.errors.full_messages.each do |msg| %>
6
+ <li><%= msg %></li>
7
+ <% end %>
8
+ </ul>
9
+ </div>
@@ -0,0 +1,17 @@
1
+ # Domain name for nginx config
2
+ set :domain_name, domain_base
3
+
4
+ # Remove www from incoming requests
5
+ set :rewrite_www, true
6
+
7
+ # Include ssl information for nginx
8
+ set :include_ssl, false
9
+
10
+ # Default, requires setting server_ip
11
+ set :default_host, true
12
+ set :server_ip, "#{server_ip}"
13
+
14
+ set :unicorn_workers, 1
15
+
16
+ set :rails_env, "production"
17
+ set :branch, "master"
@@ -0,0 +1,8 @@
1
+ set :domain_name, "demo.#{domain_base}"
2
+ set :rewrite_www, false
3
+ set :include_ssl, false
4
+ set :unicorn_workers, 1
5
+ set :default_host, false
6
+
7
+ set :rails_env, "staging"
8
+ set :branch, "staging"
@@ -0,0 +1,41 @@
1
+ # Set these values for the particular application
2
+ set :domain_base, "<%= config[:domain_base] %>"
3
+ set :server_ip, "<%= config[:server_ip] %>"
4
+ set :application, "<%= app_name %>"
5
+
6
+ # Possibly set these values
7
+ set :repository, "git@git.cliftonlabs.com:web/#{application}"
8
+ set :user, "deployer"
9
+
10
+ set :stages, %w(staging production)
11
+ set :default_stage, "staging"
12
+
13
+ require "capistrano/ext/multistage"
14
+ require "bundler/capistrano"
15
+
16
+ load "config/recipes/base"
17
+ load "config/recipes/nginx"
18
+ load "config/recipes/unicorn"
19
+ load "config/recipes/postgresql"
20
+ load "config/recipes/check"
21
+ load "config/recipes/logrotate"
22
+ load "config/recipes/log"
23
+
24
+ server server_ip, :web, :app, :db, primary: true
25
+
26
+ set :shared_children, shared_children + %w{public/uploads}
27
+
28
+ set :deploy_via, :remote_cache
29
+ set :use_sudo, false
30
+ set :deploy_to, defer { "/home/#{user}/#{application}/#{stage}/" }
31
+
32
+ set :default_environment, {
33
+ 'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
34
+ }
35
+
36
+ set :scm, "git"
37
+
38
+ default_run_options[:pty] = true
39
+ ssh_options[:forward_agent] = true
40
+
41
+ after "deploy", "deploy:cleanup" # keep only the last 5 releases
@@ -0,0 +1,45 @@
1
+ Meridian::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger
20
+ config.active_support.deprecation = :log
21
+
22
+ # Only use best-standards-support built into browsers
23
+ config.action_dispatch.best_standards_support = :builtin
24
+
25
+ # Raise exception on mass assignment protection for Active Record models
26
+ config.active_record.mass_assignment_sanitizer = :strict
27
+
28
+ # Log the query plan for queries taking more than this (works
29
+ # with SQLite, MySQL, and PostgreSQL)
30
+ config.active_record.auto_explain_threshold_in_seconds = 0.5
31
+
32
+ # Do not compress assets
33
+ config.assets.compress = false
34
+
35
+ # Expands the lines which load the assets
36
+ config.assets.debug = true
37
+
38
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
39
+
40
+ config.action_mailer.delivery_method = :letter_opener
41
+
42
+ # Add the fonts path
43
+ config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
44
+
45
+ end
@@ -0,0 +1,70 @@
1
+ Meridian::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+
11
+ # Disable Rails's static asset server (Apache or nginx will already do this)
12
+ config.serve_static_assets = false
13
+
14
+ # Compress JavaScripts and CSS
15
+ config.assets.compress = true
16
+
17
+ # Don't fallback to assets pipeline if a precompiled asset is missed
18
+ config.assets.compile = false
19
+
20
+ # Generate digests for assets URLs
21
+ config.assets.digest = true
22
+
23
+ # Add the fonts path
24
+ config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
25
+
26
+ # Precompile additional assets
27
+ config.assets.precompile += %w( .svg .eot .woff .ttf )
28
+
29
+ # Defaults to nil and saved in location specified by config.assets.prefix
30
+ # config.assets.manifest = YOUR_PATH
31
+
32
+ # Specifies the header that your server uses for sending files
33
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
34
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
35
+
36
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
37
+ # config.force_ssl = true
38
+
39
+ # See everything in the log (default is :info)
40
+ # config.log_level = :debug
41
+
42
+ # Prepend all log lines with the following tags
43
+ # config.log_tags = [ :subdomain, :uuid ]
44
+
45
+ # Use a different logger for distributed setups
46
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
47
+
48
+ # Use a different cache store in production
49
+ # config.cache_store = :mem_cache_store
50
+
51
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
52
+ # config.action_controller.asset_host = "http://assets.example.com"
53
+
54
+ # Disable delivery errors, bad email addresses will be ignored
55
+ # config.action_mailer.raise_delivery_errors = false
56
+
57
+ # Enable threaded mode
58
+ # config.threadsafe!
59
+
60
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
61
+ # the I18n.default_locale when a translation can not be found)
62
+ config.i18n.fallbacks = true
63
+
64
+ # Send deprecation notices to registered listeners
65
+ config.active_support.deprecation = :notify
66
+
67
+ # Log the query plan for queries taking more than this (works
68
+ # with SQLite, MySQL, and PostgreSQL)
69
+ # config.active_record.auto_explain_threshold_in_seconds = 0.5
70
+ end
@@ -0,0 +1,68 @@
1
+ Meridian::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+
11
+ # Disable Rails's static asset server (Apache or nginx will already do this)
12
+ config.serve_static_assets = false
13
+
14
+ # Compress JavaScripts and CSS
15
+ config.assets.compress = true
16
+
17
+ # Don't fallback to assets pipeline if a precompiled asset is missed
18
+ config.assets.compile = false
19
+
20
+ # Generate digests for assets URLs
21
+ config.assets.digest = true
22
+
23
+ # Defaults to nil and saved in location specified by config.assets.prefix
24
+ # config.assets.manifest = YOUR_PATH
25
+
26
+ # Specifies the header that your server uses for sending files
27
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
+ config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
+
30
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
+ # config.force_ssl = true
32
+
33
+ # See everything in the log (default is :info)
34
+ config.log_level = :debug
35
+
36
+ # Prepend all log lines with the following tags
37
+ # config.log_tags = [ :subdomain, :uuid ]
38
+
39
+ # Use a different logger for distributed setups
40
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
41
+
42
+ # Use a different cache store in production
43
+ # config.cache_store = :mem_cache_store
44
+
45
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
46
+ # config.action_controller.asset_host = "http://assets.example.com"
47
+
48
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
49
+ config.assets.precompile += %w( application.css.scss )
50
+
51
+ # Disable delivery errors, bad email addresses will be ignored
52
+ # config.action_mailer.raise_delivery_errors = false
53
+
54
+ # Enable threaded mode
55
+ # config.threadsafe!
56
+
57
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
58
+ # the I18n.default_locale when a translation can not be found)
59
+ config.i18n.fallbacks = true
60
+
61
+ # Send deprecation notices to registered listeners
62
+ config.active_support.deprecation = :notify
63
+
64
+ # Log the query plan for queries taking more than this (works
65
+ # with SQLite, MySQL, and PostgreSQL)
66
+ # config.active_record.auto_explain_threshold_in_seconds = 0.5
67
+
68
+ end
@@ -0,0 +1,37 @@
1
+ Meridian::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Configure static asset server for tests with Cache-Control for performance
11
+ config.serve_static_assets = true
12
+ config.static_cache_control = "public, max-age=3600"
13
+
14
+ # Log error messages when you accidentally call methods on nil
15
+ config.whiny_nils = true
16
+
17
+ # Show full error reports and disable caching
18
+ config.consider_all_requests_local = true
19
+ config.action_controller.perform_caching = false
20
+
21
+ # Raise exceptions instead of rendering exception templates
22
+ config.action_dispatch.show_exceptions = false
23
+
24
+ # Disable request forgery protection in test environment
25
+ config.action_controller.allow_forgery_protection = false
26
+
27
+ # Tell Action Mailer not to deliver emails to the real world.
28
+ # The :test delivery method accumulates sent emails in the
29
+ # ActionMailer::Base.deliveries array.
30
+ config.action_mailer.delivery_method = :test
31
+
32
+ # Raise exception on mass assignment protection for Active Record models
33
+ config.active_record.mass_assignment_sanitizer = :strict
34
+
35
+ # Print deprecation notices to the stderr
36
+ config.active_support.deprecation = :stderr
37
+ end
@@ -0,0 +1 @@
1
+ BetterErrors.editor = :sublime if defined? BetterErrors
@@ -0,0 +1,4 @@
1
+ if defined?(JazzHands)
2
+ JazzHands.colored_prompt = false
3
+ JazzHands.enable_syntax_highlighting_as_you_type!
4
+ end
@@ -0,0 +1,8 @@
1
+ def template(from, to)
2
+ erb = File.read(File.expand_path("../templates/#{from}", __FILE__))
3
+ put ERB.new(erb).result(binding), to
4
+ end
5
+
6
+ def set_default(name, *args, &block)
7
+ set(name, *args, &block) unless exists?(name)
8
+ end
@@ -0,0 +1,14 @@
1
+ namespace :check do
2
+ desc "Make sure local git is in sync with remote."
3
+ task :revision, roles: :web do
4
+ current_repository = "origin"
5
+ unless (`git rev-parse HEAD` == `git rev-parse #{current_repository}/#{branch}`)
6
+ puts "WARNING: HEAD is not the same as #{current_repository}/#{branch}"
7
+ puts "Run `git push` to sync changes."
8
+ exit
9
+ end
10
+ end
11
+ before "deploy", "check:revision"
12
+ before "deploy:migrations", "check:revision"
13
+ before "deploy:cold", "check:revision"
14
+ end
@@ -0,0 +1,6 @@
1
+ namespace :log do
2
+ desc "View log tail"
3
+ task :tail, roles: :app do
4
+ run "tail #{shared_path}/log/#{rails_env}.log -n 50"
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ namespace :logrotate do
2
+ desc "Setup logrotate for all log files in log directory"
3
+ task :setup, roles: :app do
4
+ template "logrotate.erb", "/tmp/logrotate"
5
+ run "#{sudo} mv /tmp/logrotate /etc/logrotate.d/#{application}_#{stage}"
6
+ end
7
+ after "deploy:setup", "logrotate:setup"
8
+ end
@@ -0,0 +1,17 @@
1
+ namespace :nginx do
2
+ desc "Setup nginx configuration for this application"
3
+ task :setup, roles: :web do
4
+ template "nginx_unicorn.erb", "/tmp/nginx_conf"
5
+ run "#{sudo} mv /tmp/nginx_conf /etc/nginx/sites-enabled/#{application}_#{stage}"
6
+ run "#{sudo} rm -f /etc/nginx/sites-enabled/default"
7
+ restart
8
+ end
9
+ after "deploy:setup", "nginx:setup"
10
+
11
+ %w[start stop restart].each do |command|
12
+ desc "#{command} nginx"
13
+ task command, roles: :web do
14
+ run "#{sudo} service nginx #{command}"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,32 @@
1
+ set_default(:postgresql_host, "localhost")
2
+ set_default(:postgresql_user) { application }
3
+ set_default(:postgresql_password) { Capistrano::CLI.password_prompt "PostgreSQL Password: " }
4
+ set_default(:postgresql_database) { "#{application}_#{rails_env}" }
5
+ set_default(:postgresql_pid) { "/var/run/postgresql/9.1-main.pid" }
6
+
7
+ namespace :postgresql do
8
+ desc "Create a user for this application."
9
+ task :create_user, roles: :db, only: {primary: true} do
10
+ run %Q{#{sudo} -u postgres psql -c "create user \"#{postgresql_user}\" with password '#{postgresql_password}';"; true}
11
+ end
12
+ after "deploy:setup", "postgresql:create_user"
13
+
14
+ desc "Create a database for this application."
15
+ task :create_database, roles: :db, only: {primary: true} do
16
+ run %Q{#{sudo} -u postgres psql -c "create database \"#{postgresql_database}\" owner \"#{postgresql_user}\";"; true}
17
+ end
18
+ after "deploy:setup", "postgresql:create_database"
19
+
20
+ desc "Generate the database.yml configuration file."
21
+ task :setup, roles: :app do
22
+ run "mkdir -p #{shared_path}/config"
23
+ template "postgresql.yml.erb", "#{shared_path}/config/database.yml"
24
+ end
25
+ after "deploy:setup", "postgresql:setup"
26
+
27
+ desc "Symlink the database.yml file into latest release"
28
+ task :symlink, roles: :app do
29
+ run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
30
+ end
31
+ after "deploy:finalize_update", "postgresql:symlink"
32
+ end
@@ -0,0 +1,23 @@
1
+ CREATE OR REPLACE FUNCTION create_role_if_not_exists(r_name TEXT, r_pass TEXT)
2
+ RETURNS void AS $$
3
+ BEGIN
4
+ IF NOT EXISTS (
5
+ SELECT *
6
+ FROM pg_catalog.pg_user
7
+ WHERE usename = $1) THEN
8
+ EXECUTE format('CREATE ROLE %s LOGIN PASSWORD ''%s'' CREATEDB', $1, $2);
9
+ END IF;
10
+ END;
11
+ $$ LANGUAGE plpgsql;
12
+
13
+ CREATE OR REPLACE FUNCTION create_database_if_not_exists(db_name TEXT, db_owner TEXT)
14
+ RETURNS void AS $$
15
+ BEGIN
16
+ IF NOT EXISTS (
17
+ SELECT *
18
+ FROM pg_catalog.pg_database
19
+ WHERE datname = $1) THEN
20
+ EXECUTE format('CREATE DATABASE %s OWNER %s', $1, $2);
21
+ END IF;
22
+ END;
23
+ $$ LANGUAGE plpgsql;
@@ -0,0 +1,9 @@
1
+ /home/<%= user %>/<%= application %>/<%= stage %>/shared/log/*.log {
2
+ weekly
3
+ missingok
4
+ rotate 52
5
+ compress
6
+ delaycompress
7
+ notifempty
8
+ copytruncate
9
+ }
@@ -0,0 +1,69 @@
1
+ upstream unicorn_<%= "#{application}_#{rails_env}" %> {
2
+ server unix:/tmp/unicorn.<%= "#{application}_#{rails_env}" %>.sock fail_timeout=0;
3
+ }
4
+
5
+ <% if rewrite_www %>
6
+ ##############################
7
+ # Rewrite non-www to www #
8
+ ##############################
9
+ server {
10
+ server_name www.<%= domain_name %>;
11
+ rewrite ^(.*) http://<%= domain_name %>$1 permanent;
12
+ }
13
+ <% end %>
14
+
15
+ ############################
16
+ # Server configuration #
17
+ ############################
18
+ server {
19
+ listen 80<%= " default_server" if (defined? default_host) && default_host %>;
20
+ server_name <%= domain_name %>;
21
+ root /home/<%= user %>/<%= application %>/<%= stage %>/current/public;
22
+
23
+ location ^~ /assets/ {
24
+ gzip_static on;
25
+ expires max;
26
+ add_header Cache-Control public;
27
+ }
28
+
29
+ try_files $uri @unicorn;
30
+ location @unicorn {
31
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
32
+ proxy_set_header Host $http_host;
33
+ proxy_redirect off;
34
+ proxy_pass http://unicorn_<%= application %>_<%= stage %>;
35
+ }
36
+
37
+ error_page 500 502 503 504 /500.html;
38
+ client_max_body_size 4G;
39
+ keepalive_timeout 10;
40
+ }
41
+
42
+ <% if include_ssl %>
43
+ server {
44
+ listen 443;
45
+ server_name <%= domain_name %>;
46
+ ssl on;
47
+ ssl_certificate /path/to/certificate/certificate.combined.crt;
48
+ ssl_certificate_key /path/to/key/server.key;
49
+ root /home/<%= user %>/apps/<%= application %>/<%= stage %>/current/public;
50
+
51
+ location ^~ /assets/ {
52
+ gzip_static on;
53
+ expires max;
54
+ add_header Cache-Control public;
55
+ }
56
+
57
+ try_files $uri @unicorn;
58
+ location @unicorn {
59
+ proxy_set_header X-Forwarded-Proto $scheme;
60
+ proxy_set_header Host $http_host;
61
+ proxy_redirect off;
62
+ proxy_pass http://unicorn_<%= application %>_<%= stage %>;
63
+ }
64
+
65
+ error_page 500 502 503 504 /500.html;
66
+ client_max_body_size 4G;
67
+ keepalive_timeout 10;
68
+ }
69
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <%= rails_env %>:
2
+ adapter: postgresql
3
+ encoding: unicode
4
+ database: <%= postgresql_database %>
5
+ pool: 5
6
+ username: <%= postgresql_user %>
7
+ password: <%= postgresql_password %>
8
+ host: <%= postgresql_host %>
@@ -0,0 +1,14 @@
1
+ working_directory "<%= current_path %>"
2
+ pid "<%= unicorn_pid %>"
3
+ stderr_path "<%= unicorn_log %>"
4
+ stdout_path "<%= unicorn_log %>"
5
+ preload_app true
6
+
7
+ listen "/tmp/unicorn.<%= "#{application}_#{stage}" %>.sock"
8
+ worker_processes <%= unicorn_workers %>
9
+ timeout 30
10
+
11
+ after_fork do |server, worker|
12
+ child_pid = server.config[:pid].sub(".pid", "#{worker.nr}.pid")
13
+ system("echo #{Process.pid} > #{child_pid}")
14
+ end