capistrano-fiftyfive 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/CHANGELOG.md +5 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +164 -0
  7. data/Rakefile +1 -0
  8. data/capistrano-fiftyfive.gemspec +30 -0
  9. data/lib/capistrano/fiftyfive/compatibility.rb +17 -0
  10. data/lib/capistrano/fiftyfive/console.rb +61 -0
  11. data/lib/capistrano/fiftyfive/dsl.rb +140 -0
  12. data/lib/capistrano/fiftyfive/recipe.rb +48 -0
  13. data/lib/capistrano/fiftyfive/templates/crontab.erb +1 -0
  14. data/lib/capistrano/fiftyfive/templates/csr_config.erb +10 -0
  15. data/lib/capistrano/fiftyfive/templates/delayed_job_init.erb +36 -0
  16. data/lib/capistrano/fiftyfive/templates/logrotate.erb +9 -0
  17. data/lib/capistrano/fiftyfive/templates/maintenance.html.erb +26 -0
  18. data/lib/capistrano/fiftyfive/templates/nginx.erb +60 -0
  19. data/lib/capistrano/fiftyfive/templates/nginx_unicorn.erb +100 -0
  20. data/lib/capistrano/fiftyfive/templates/pgpass.erb +1 -0
  21. data/lib/capistrano/fiftyfive/templates/postgresql-backup-logrotate.erb +11 -0
  22. data/lib/capistrano/fiftyfive/templates/postgresql.yml.erb +8 -0
  23. data/lib/capistrano/fiftyfive/templates/rbenv_bashrc +4 -0
  24. data/lib/capistrano/fiftyfive/templates/sidekiq_init.erb +100 -0
  25. data/lib/capistrano/fiftyfive/templates/ssl_setup +43 -0
  26. data/lib/capistrano/fiftyfive/templates/unicorn.rb.erb +71 -0
  27. data/lib/capistrano/fiftyfive/templates/unicorn_init.erb +84 -0
  28. data/lib/capistrano/fiftyfive/templates/version.rb.erb +2 -0
  29. data/lib/capistrano/fiftyfive/version.rb +5 -0
  30. data/lib/capistrano/fiftyfive.rb +28 -0
  31. data/lib/capistrano/tasks/aptitude.rake +77 -0
  32. data/lib/capistrano/tasks/crontab.rake +14 -0
  33. data/lib/capistrano/tasks/defaults.rake +124 -0
  34. data/lib/capistrano/tasks/delayed_job.rake +32 -0
  35. data/lib/capistrano/tasks/dotenv.rake +53 -0
  36. data/lib/capistrano/tasks/logrotate.rake +15 -0
  37. data/lib/capistrano/tasks/maintenance.rake +28 -0
  38. data/lib/capistrano/tasks/migrate.rake +29 -0
  39. data/lib/capistrano/tasks/nginx.rake +30 -0
  40. data/lib/capistrano/tasks/postgresql.rake +103 -0
  41. data/lib/capistrano/tasks/rake.rake +20 -0
  42. data/lib/capistrano/tasks/rbenv.rake +92 -0
  43. data/lib/capistrano/tasks/seed.rake +16 -0
  44. data/lib/capistrano/tasks/sidekiq.rake +38 -0
  45. data/lib/capistrano/tasks/ssl.rake +52 -0
  46. data/lib/capistrano/tasks/ufw.rake +32 -0
  47. data/lib/capistrano/tasks/unicorn.rake +41 -0
  48. data/lib/capistrano/tasks/user.rake +29 -0
  49. data/lib/capistrano/tasks/version.rake +31 -0
  50. data/lib/sshkit/formatter/abbreviated.rb +148 -0
  51. metadata +165 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 24b1413c65db68ecf7cfa640483d863ae19d910f
4
+ data.tar.gz: ef376f1cd739af9b21f61787f91e1f06b68d151c
5
+ SHA512:
6
+ metadata.gz: 431fa3a8dd368a43c5cd2ebd62c0c7dc9b8204918c5c8d1067e7b002dd02de6f92859aef08f70f4d27d03aab85bc9964fcffb8c7d4a725df666282abfea12769
7
+ data.tar.gz: 8a2a6abc2ef46dbe76ec15723b4a93f9ab80dadec26ef271b211fbadae77464c091a8934214565a08ed6145fa432165e06b6dd9330640e5762f9d40d36acc432
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # capistrano-fiftyfive Changelog
2
+
3
+ ## `0.9.0`
4
+
5
+ Initial Rubygems release!
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-fiftyfive.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 55 Minutes Inc
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,164 @@
1
+ # capistrano-fiftyfive
2
+
3
+ Capistrano is great for deploying Rails applications, but what about all the prerequisites, like Nginx and PostgreSQL? Do you have a firewall configured on your VPS? Have you installed the latest OS security updates? Is HTTPS working right?
4
+
5
+ The capistrano-fiftyfive gem adds a `cap <stage> provision` task to Capistrano that takes care of all that. Out of the box, `provision` will:
6
+
7
+ * Install the latest `postgresql`, `node.js`, and `nginx` apt packages
8
+ * Install all libraries needed to build Ruby
9
+ * Lock down your VPS using `ufw` (a simple front-end to iptables)
10
+ * Set up `logrotated` for your Rails logs
11
+ * Schedule an automatic daily backup of your Rails database
12
+ * Generate a self-signed SSL certificate if you need one
13
+ * Set up ngnix with the latest SSL practices and integrate it with Unicorn for your Rails app
14
+ * Create the `deployer` user and install an SSH public key
15
+ * Install `rbenv` and use `ruby-build` to compile the version of Ruby required by your app (by inspecting your `.ruby-version` file)
16
+ * And more!
17
+
18
+ The gem is named "capistrano-fiftyfive" because it is built first and foremost for serving our deployment needs here at [55 Minutes](http://55minutes.com). You'll notice that capistrano-fiftyfive is opinionated and strictly uses the following stack:
19
+
20
+ * Ubuntu 12.04 LTS
21
+ * PostgreSQL
22
+ * Unicorn
23
+ * Nginx
24
+ * rbenv
25
+ * dotenv
26
+
27
+ In addition, capistrano-fiftyfive changes many of Capistrano's defaults, including the deployment location, Bundler behavior, and SSH keep-alive settings. It also overhauls and simplifies the logging format. (See [defaults.rake][] for details.)
28
+
29
+ Not quite to your liking? Consider forking the project to meet your needs.
30
+
31
+
32
+ ## Installation
33
+
34
+ Please note that this project requires **Capistrano 3.x**, which is a complete
35
+ rewrite of Capistrano 2.x. The two major versions are not compatible.
36
+
37
+ ### 1. Gemfile
38
+
39
+ Add these gems to the development group of your Rails application's Gemfile:
40
+
41
+ group :development do
42
+ gem 'capistrano-bundler', :require => false
43
+ gem 'capistrano-rails', :require => false
44
+ gem 'capistrano', '~> 3.2.1', :require => false
45
+ gem 'capistrano-fiftyfive', '~> 0.9.0', :require => false
46
+ end
47
+
48
+ And then execute:
49
+
50
+ $ bundle
51
+
52
+
53
+ ### 2. cap install
54
+
55
+ If your project doesn't yet have a `Capfile`, run `cap install` with the list
56
+ of desired stages (environments):
57
+
58
+ cap install STAGES=staging,production
59
+
60
+
61
+ ### 3. Capfile
62
+
63
+ Add these lines to the **bottom** of your app's `Capfile`
64
+ (order is important!):
65
+
66
+ require 'capistrano/bundler'
67
+ require 'capistrano/rails'
68
+ require 'capistrano/fiftyfive'
69
+
70
+
71
+ ### 4. Choose which recipes to auto-run
72
+
73
+ Most of the capistrano-fiftyfive recipes are designed to run automatically as part of `cap <stage> provision`, for installing and setting up various bits of the Rails infrastructure, like nginx, unicorn, and postgres. Some recipes also contribute to the `cap <stage> deploy` process.
74
+
75
+ *This auto-run behavior is fully under your control.* In your `deploy.rb`,
76
+ set `:fiftyfive_recipes` to an array of the desired recipes.
77
+ If you don't want a recipe to execute as part of `deploy`/`provision`, simply omit it from
78
+ the list.
79
+
80
+ The following list will suffice for most out-of-the-box Rails apps. The order of the list is not important.
81
+
82
+ set :fiftyfive_recipes, %w(
83
+ aptitude
84
+ crontab
85
+ dotenv
86
+ logrotate
87
+ migrate
88
+ nginx
89
+ postgresql
90
+ rbenv
91
+ seed
92
+ ssl
93
+ ufw
94
+ unicorn
95
+ user
96
+ version
97
+ )
98
+
99
+ Even if you don't include a recipe in the auto-run list, you can still invoke
100
+ the tasks of those recipes manually at your discretion.
101
+
102
+
103
+ ### 5. Configuration
104
+
105
+ Many of the recipes have default settings that can be overridden. Use your
106
+ `deploy.rb` file to specify these overrides. Or, you can override per stage.
107
+ Here is an example override:
108
+
109
+ set :fiftyfive_unicorn_workers, 8
110
+
111
+ For the full list of settings and their default values, refer to
112
+ [defaults.rake][].
113
+
114
+
115
+ ### A working example
116
+
117
+ Check out our [rails-starter][] project for a sample Capfile and deploy.rb.
118
+
119
+ ## Usage
120
+
121
+ The power of the capistrano-fiftyfive recipes is that they take care of the
122
+ entire setup of a bare Ubuntu 12.04 server, all the way to a fully configured
123
+ and running Rails app on top up Unicorn, Nginx, rbenv, and PostgreSQL.
124
+
125
+ ### Deploying to a new server from scratch
126
+
127
+ These steps assume you have loaded the full set of capistrano-fiftyfive
128
+ recipes in your Capfile.
129
+
130
+ 1. Provision an Ubuntu 12.04 VPS at your hosting provider of choice.
131
+ 2. Install your public SSH key for the root user. Some providers (e.g. DigitalOcean) can do this for you automatically when you provision a new VPS.
132
+ 3. Repeat steps 1-2 for all the servers in your cluster, if you are using
133
+ a multi-server setup (e.g. separate web, app, and database servers).
134
+ 4. Let capistrano-fiftyfive take it from here:
135
+
136
+ cap staging provision
137
+ cap staging deploy
138
+
139
+ ### Running individual tasks
140
+
141
+ For a full description of all available tasks, run:
142
+
143
+ cap -T
144
+
145
+ All tasks from capistrano-fiftyfive will be prefixed with `fiftyfive:`. You
146
+ can run these tasks just like any other capistrano task, like so:
147
+
148
+ cap staging fiftyfive:seed
149
+
150
+
151
+ ## Contributing
152
+
153
+ 1. Fork it
154
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
155
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
156
+ 4. Push to the branch (`git push origin my-new-feature`)
157
+ 5. Create new Pull Request
158
+
159
+
160
+ [Postmark]:https://postmarkapp.com
161
+ [cast337]:http://railscasts.com/episodes/337-capistrano-recipes
162
+ [cast373]:http://railscasts.com/episodes/373-zero-downtime-deployment
163
+ [defaults.rake]:lib/capistrano/tasks/defaults.rake
164
+ [rails-starter]:https://github.com/55minutes/rails-starter/tree/master/config
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/fiftyfive/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-fiftyfive"
8
+ spec.version = Capistrano::Fiftyfive::VERSION
9
+ spec.authors = ["Matt Brictson"]
10
+ spec.email = ["opensource@55minutes.com"]
11
+ spec.description = \
12
+ "Capistrano 3.1+ recipes that we use at 55 Minutes to standardize "\
13
+ "our Rails deployments. These are tailored for Ubuntu 12.04 LTS, "\
14
+ "PostgreSQL, Nginx, Unicorn, rbenv, and Rails 3/4."
15
+ spec.summary = %q{Additional Capistrano recipes from 55 Minutes}
16
+ spec.homepage = "https://github.com/55minutes/capistrano-fiftyfive"
17
+ spec.license = "MIT"
18
+
19
+ spec.files = `git ls-files`.split($/)
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "capistrano", ">= 3.2.1"
25
+ spec.add_dependency "sshkit", ">= 1.4.0"
26
+ spec.add_dependency "colorize"
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.3"
29
+ spec.add_development_dependency "rake"
30
+ end
@@ -0,0 +1,17 @@
1
+ require 'colorize'
2
+
3
+ unless defined?(Capistrano) && defined?(:namespace)
4
+ $stderr.puts\
5
+ "WARNING: capistrano/fiftyfive must be loaded by Capistrano in order "\
6
+ "to work.\nRequire this gem by using Capistrano's Capfile, "\
7
+ "as described here:\n"\
8
+ "https://github.com/55minutes/capistrano-fiftyfive#installation"\
9
+ .colorize(:red)
10
+ end
11
+
12
+ if Capistrano::VERSION == "3.2.0"
13
+ $stderr.puts\
14
+ "WARNING: Capistrano 3.2.0 has a critical bug that prevents "\
15
+ "capistrano-fiftyfive from working as intended:\n"\
16
+ "https://github.com/capistrano/capistrano/issues/1004".colorize(:red)
17
+ end
@@ -0,0 +1,61 @@
1
+ require 'io/console'
2
+
3
+ module Capistrano
4
+ module Fiftyfive
5
+ # Helper class that wraps an IO object and provides methods for truncating
6
+ # output, assuming the IO object represents a console window.
7
+ #
8
+ # This is useful for writing log messages that will typically show up on
9
+ # an ANSI color-capable console. When a console is not present (e.g. when
10
+ # running on a CI server) the output will gracefully degrade.
11
+ class Console
12
+ def initialize(output)
13
+ @output = output
14
+ end
15
+
16
+ # Writes to the IO after first truncating the output to fit the console
17
+ # width. If the underlying IO is not a TTY, ANSI colors are removed from
18
+ # the output. A newline is always added.
19
+ def print_line(obj)
20
+ string = obj.to_s
21
+
22
+ if @output.tty?
23
+ string = truncate_to_console_width(string)
24
+ else
25
+ string = strip_ascii_color(string)
26
+ end
27
+
28
+ write(string + "\n")
29
+ end
30
+
31
+ # Writes directly through to the IO with no truncation or color logic.
32
+ # No newline is added.
33
+ def write(string)
34
+ @output.write(string || "")
35
+ end
36
+ alias_method :<<, :write
37
+
38
+ def truncate_to_console_width(string)
39
+ string = (string || "").rstrip
40
+ width = console_width
41
+
42
+ if strip_ascii_color(string).length > width
43
+ while strip_ascii_color(string).length >= width
44
+ string.chop!
45
+ end
46
+ string << "…\e[0m"
47
+ else
48
+ string
49
+ end
50
+ end
51
+
52
+ def strip_ascii_color(string)
53
+ (string || "").gsub(/\033\[[0-9;]*m/, "")
54
+ end
55
+
56
+ def console_width
57
+ IO.console.winsize.last if @output.tty?
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,140 @@
1
+ module Capistrano
2
+ module Fiftyfive
3
+ module DSL
4
+
5
+ # Invoke the given task. If a task with that name is not defined,
6
+ # silently skip it.
7
+ #
8
+ def invoke_if_defined(task)
9
+ invoke(task) if Rake::Task.task_defined?(task)
10
+ end
11
+
12
+ # Used internally by capistrano-fiftyfive to register tasks such that
13
+ # those tasks are executed conditionally based on the presence of the
14
+ # recipe name in fetch(:fiftyfive_recipes).
15
+ #
16
+ # fiftyfive_recipe :aptitude do
17
+ # during :provision, %w(task1 task2 ...)
18
+ # end
19
+ #
20
+ def fiftyfive_recipe(recipe_name, &block)
21
+ Recipe.new(recipe_name).instance_exec(&block)
22
+ end
23
+
24
+ # Helper for calling fetch(:application) and making the value safe for
25
+ # using in filenames, usernames, etc. Replaces non-word characters with
26
+ # underscores.
27
+ #
28
+ def application_basename
29
+ fetch(:application).to_s.gsub(/[^a-zA-Z0-9_]/, "_")
30
+ end
31
+
32
+ # Like capistrano's built-in ask(), but does not echo user input.
33
+ # Suitable for passwords, etc. Requires the highline gem.
34
+ #
35
+ # ask_secretly(:postgresql_password)
36
+ #
37
+ def ask_secretly(key, default=nil)
38
+ require "highline"
39
+ set key, proc{
40
+ hint = default ? " [#{default}]" : ""
41
+ answer = HighLine.new.ask("Enter #{key}#{hint}: ") do |q|
42
+ q.echo = false
43
+ end.to_s
44
+ }
45
+ end
46
+
47
+ # Like capistrano's built-in on(), but connects to the server as root.
48
+ # To use a user other than root, set :fiftyfive_privileged_user or
49
+ # specify :privileged_user as a server property.
50
+ #
51
+ # task :reboot do
52
+ # privileged_on roles(:all) do
53
+ # execute :shutdown, "-r", "now"
54
+ # end
55
+ # end
56
+ #
57
+ def privileged_on(*args, &block)
58
+ on(*args) do |host|
59
+ if host.nil?
60
+ instance_exec(nil, nil, &block)
61
+ else
62
+ original_user = host.user
63
+
64
+ begin
65
+ host.user = host.properties.privileged_user ||
66
+ fetch(:fiftyfive_privileged_user)
67
+ instance_exec(host, original_user, &block)
68
+ ensure
69
+ host.user = original_user
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ # Uploads the given string or file-like object to the current host
76
+ # context. Intended to be used within an on() or privileged_on() block.
77
+ # Accepts :owner and :mode options that affect the permissions of the
78
+ # remote file.
79
+ #
80
+ def put(string_or_io, remote_path, opts={})
81
+ owner = opts[:owner]
82
+ mode = opts[:mode]
83
+
84
+ source = if string_or_io.respond_to?(:read)
85
+ string_or_io
86
+ else
87
+ StringIO.new(string_or_io.to_s)
88
+ end
89
+
90
+ execute :mkdir, "-p", File.dirname(remote_path)
91
+
92
+ upload!(source, remote_path)
93
+
94
+ execute(:chown, owner, remote_path) if owner
95
+ execute(:chmod, mode, remote_path) if mode
96
+ end
97
+
98
+
99
+ # Read the specified file from the local system, interpret it as ERb,
100
+ # and upload it to the current host context. Intended to be used with an
101
+ # on() or privileged_on() block. Accepts :owner, :mode, and :binding
102
+ # options.
103
+ #
104
+ # Templates with relative paths are first searched for in
105
+ # lib/capistrano/fiftyfive/templates in the current project. This gives
106
+ # applications a chance to override. If an override is not found, the
107
+ # default template within the capistrano-fiftyfive gem is used.
108
+ #
109
+ # task :create_database_yml do
110
+ # on roles(:app, :db) do
111
+ # within(shared_path) do
112
+ # template fetch(:database_yml_template_path),
113
+ # "config/database.yml",
114
+ # :mode => "600"
115
+ # end
116
+ # end
117
+ # end
118
+ #
119
+ def template(local_path, remote_path, opts={})
120
+ binding = opts[:binding] || binding
121
+
122
+ unless local_path.start_with?("/")
123
+ override_path = \
124
+ File.join("lib/capistrano/fiftyfive/templates", local_path)
125
+
126
+ local_path = if File.exist?(override_path)
127
+ override_path
128
+ else
129
+ File.expand_path(File.join("../templates", local_path), __FILE__)
130
+ end
131
+ end
132
+
133
+ erb = File.read(local_path)
134
+ rendered_template = ERB.new(erb).result(binding)
135
+
136
+ put(rendered_template, remote_path, opts)
137
+ end
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,48 @@
1
+ module Capistrano
2
+ module Fiftyfive
3
+ class Recipe
4
+ attr_reader :name
5
+
6
+ def initialize(name)
7
+ @name = name.to_s
8
+ end
9
+
10
+ def enabled?
11
+ fetch(:fiftyfive_recipes, []).map(&:to_s).include?(name)
12
+ end
13
+
14
+ def prior_to(task_to_extend, *recipe_tasks)
15
+ inject_tasks(:before, task_to_extend, *recipe_tasks)
16
+ end
17
+
18
+ def during(task_to_extend, *recipe_tasks)
19
+ inject_tasks(:after, task_to_extend, *recipe_tasks)
20
+ end
21
+
22
+ private
23
+
24
+ def inject_tasks(method, task_to_extend, *recipe_tasks)
25
+ create_task_unless_exists(task_to_extend)
26
+
27
+ recipe_tasks.flatten.each do |task|
28
+ qualified_task = apply_namespace(task)
29
+ send(method, task_to_extend, "#{qualified_task}:if_enabled") do
30
+ invoke qualified_task if enabled?
31
+ end
32
+ end
33
+ end
34
+
35
+ def apply_namespace(task_name)
36
+ return task_name if task_name.include?(":")
37
+
38
+ "fiftyfive:#{name}:#{task_name}"
39
+ end
40
+
41
+ def create_task_unless_exists(task_name)
42
+ unless Rake::Task.task_defined?(task_name)
43
+ Rake::Task.define_task(task_name)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1 @@
1
+ # Sample crontab (empty)
@@ -0,0 +1,10 @@
1
+ [ req ]
2
+ distinguished_name="req_distinguished_name"
3
+ prompt="no"
4
+
5
+ [ req_distinguished_name ]
6
+ C="<%= fetch(:fiftyfive_ssl_csr_country) %>"
7
+ ST="<%= fetch(:fiftyfive_ssl_csr_state) %>"
8
+ L="<%= fetch(:fiftyfive_ssl_csr_city) %>"
9
+ O="<%= fetch(:fiftyfive_ssl_csr_org) %>"
10
+ CN="<%= fetch(:fiftyfive_ssl_csr_name) %>"
@@ -0,0 +1,36 @@
1
+ #!/bin/sh
2
+ ### BEGIN INIT INFO
3
+ # Provides: delayed_job
4
+ # Required-Start: $remote_fs $syslog
5
+ # Required-Stop: $remote_fs $syslog
6
+ # Default-Start: 2 3 4 5
7
+ # Default-Stop: 0 1 6
8
+ # Short-Description: Manage delayed_job worker
9
+ # Description: Start, stop, restart delayed_job workers for a specific application.
10
+ ### END INIT INFO
11
+ set -e
12
+
13
+ # Feel free to change any of the following variables for your app:
14
+ CMD="cd <%= current_path %>; RAILS_ENV=<%= fetch(:rails_env) %> <%= fetch(:fiftyfive_delayed_job_script) %>"
15
+ AS_USER=<%= fetch(:fiftyfive_delayed_job_user, user) %>
16
+ set -u
17
+
18
+ run () {
19
+ if [ "$(id -un)" = "$AS_USER" ]; then
20
+ eval $1
21
+ else
22
+ su -c "$1" - $AS_USER
23
+ fi
24
+ }
25
+
26
+ case "$1" in
27
+ start)
28
+ run "$CMD start <%= fetch(:fiftyfive_delayed_job_args) %>"
29
+ ;;
30
+ stop)
31
+ run "$CMD stop"
32
+ ;;
33
+ restart)
34
+ run "$CMD restart <%= fetch(:fiftyfive_delayed_job_args) %>"
35
+ ;;
36
+ esac
@@ -0,0 +1,9 @@
1
+ <%= shared_path %>/log/*.log {
2
+ daily
3
+ nomissingok
4
+ rotate 7
5
+ compress
6
+ delaycompress
7
+ notifempty
8
+ copytruncate
9
+ }
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Maintenance</title>
6
+ <style type="text/css">
7
+ body {
8
+ width: 500px;
9
+ margin: 100px auto;
10
+ font: 300 120% "OpenSans", "Helvetica Neue", "Helvetica", Arial, Verdana, sans-serif;
11
+ }
12
+
13
+ h1 {
14
+ font-weight: 300;
15
+ }
16
+ </style>
17
+ </head>
18
+ <body>
19
+ <h1>Maintenance</h1>
20
+
21
+ <p>Our systems are currently down for <%= reason ? reason : "maintenance" %><br>
22
+ as of <%= Time.now.strftime("%H:%M %Z") %>.</p>
23
+
24
+ <p>We’ll be back <%= deadline ? deadline : "shortly" %>.</p>
25
+ </body>
26
+ </html>
@@ -0,0 +1,60 @@
1
+ # Based on https://github.com/defunkt/unicorn/blob/master/examples/nginx.conf
2
+
3
+ user www-data;
4
+ pid /run/nginx.pid;
5
+ error_log /var/log/nginx/error.log;
6
+
7
+ # you generally only need one nginx worker unless you're serving
8
+ # large amounts of static files which require blocking disk reads
9
+ worker_processes 1;
10
+
11
+ events {
12
+ worker_connections 1024; # increase if you have lots of clients
13
+ accept_mutex off; # "on" if nginx worker_processes > 1
14
+ use epoll; # for Linux 2.6+
15
+ }
16
+
17
+ http {
18
+ # ensure nginx is able to load lots of third-party modules
19
+ types_hash_max_size 2048;
20
+ server_names_hash_bucket_size 64;
21
+
22
+ # nginx will find this file in the config directory set at nginx build time
23
+ include mime.types;
24
+
25
+ # fallback in case we can't determine a type
26
+ default_type application/octet-stream;
27
+
28
+ # click tracking!
29
+ access_log /var/log/nginx/access.log combined;
30
+
31
+ # you generally want to serve static files with nginx since neither
32
+ # Unicorn nor Rainbows! is optimized for it at the moment
33
+ sendfile on;
34
+
35
+ tcp_nopush on; # off may be better for *some* Comet/long-poll stuff
36
+ tcp_nodelay off; # on may be better for some Comet/long-poll stuff
37
+
38
+ # we haven't checked to see if Rack::Deflate on the app server is
39
+ # faster or not than doing compression via nginx. It's easier
40
+ # to configure it all in one place here for static files and also
41
+ # to disable gzip for clients who don't get gzip/deflate right.
42
+ # There are other gzip settings that may be needed used to deal with
43
+ # bad clients out there, see http://wiki.nginx.org/NginxHttpGzipModule
44
+ gzip on;
45
+ gzip_http_version 1.0;
46
+ gzip_proxied any;
47
+ gzip_min_length 500;
48
+ gzip_disable "MSIE [1-6]\.";
49
+ gzip_types text/plain text/xml text/css
50
+ text/comma-separated-values
51
+ text/javascript application/x-javascript
52
+ application/atom+xml;
53
+
54
+
55
+ # Allow SSL session resumption
56
+ ssl_session_cache shared:SSL:10m;
57
+
58
+ include /etc/nginx/conf.d/*.conf;
59
+ include /etc/nginx/sites-enabled/*;
60
+ }