railman 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CUSTOMIZATION.md +81 -0
- data/lib/railman/cli.rb +18 -3
- data/lib/railman/version.rb +1 -1
- data/railman.gemspec +2 -0
- data/templates/rails_app/.env.example.tt +40 -0
- data/templates/rails_app/.envrc +3 -0
- data/templates/rails_app/Eyefile.tt +40 -0
- data/templates/rails_app/Gemfile +16 -17
- data/templates/rails_app/TODO.md +14 -0
- data/templates/rails_app/config/database.yml.tt +32 -0
- data/templates/rails_app/config/deploy/production.rb.tt +4 -0
- data/templates/rails_app/config/environments/development.rb +4 -0
- data/templates/rails_app/config/environments/production.rb +19 -1
- data/templates/rails_app/config/environments/test.rb +2 -0
- data/templates/rails_app/config/locales/readme.txt +3 -0
- data/templates/rails_app/config/secrets.yml +3 -3
- data/templates/rails_app/config/server/letsencrypt.conf.tt +14 -0
- data/templates/rails_app/config/server/logrotate.conf.tt +10 -0
- data/templates/rails_app/config/server/nginx.conf.tt +70 -0
- data/templates/rails_app/config/unicorn.rb +50 -0
- metadata +42 -3
- data/templates/rails_app/config/database.yml +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eea88cb63a0d2137adc11bd0ed5dd9fce26ac383
|
4
|
+
data.tar.gz: b75caf3b59e3937873c87ab4b6ca08f98045d9e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f26aef2d81f4af9401cdcc7b773600f635cae460f0eb529db25f5f44834022ae6c034a27a5d02d4c90c4fbe447437fcec37baf91b4cec5218b11cadd5305cb83
|
7
|
+
data.tar.gz: 12734bf0fb0244b0b04f2da35299d7636c566559f2f4289b9cd863102603b53ee393da5cd362ed23f9c5409d4505b97bb9ebf368a61f54c20720006bb3f8d97e
|
data/CUSTOMIZATION.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# Customizations of the default rails application
|
2
|
+
|
3
|
+
These are the things that are different in the app template generated by railman compared to the plain app template generated by rails.
|
4
|
+
|
5
|
+
## .ruby-version
|
6
|
+
|
7
|
+
Specify your ruby version here.
|
8
|
+
|
9
|
+
## .envrc
|
10
|
+
|
11
|
+
If you install direnv, you don't have to use `bundle exec` any more, as the bin direcory is added to the PATH when you are enter the application's directory.
|
12
|
+
|
13
|
+
## Gemfile
|
14
|
+
|
15
|
+
Add following gems:
|
16
|
+
pg - postgres database driver
|
17
|
+
exception_notification - notify me per email on each exception
|
18
|
+
letter_opener - open emails in popup window in the browser in development mode
|
19
|
+
|
20
|
+
Remove following gems:
|
21
|
+
sqlite3 - we are using postgres per default
|
22
|
+
|
23
|
+
Add the application-specific gems to Gemfile.local, so it can be kept separate from the base Gemfile.
|
24
|
+
|
25
|
+
## Eyefile
|
26
|
+
|
27
|
+
[Eye](https://github.com/kostya/eye) is a ruby process manager. We use it to start/stop/restart/monitor the application ruby processes.
|
28
|
+
|
29
|
+
The configuration of the processes that the application includes (app server, workers) is in the Eyefile.
|
30
|
+
|
31
|
+
The eye gem is not included in the Gemfile. Eye should be installed globally on the server or your local machine and there will be only one eye process that manages multiple rails applications.
|
32
|
+
|
33
|
+
## .env.example
|
34
|
+
|
35
|
+
This is a template for the application- and server-specific .env file.
|
36
|
+
|
37
|
+
## config/deploy/production.rb
|
38
|
+
|
39
|
+
config/deploy includes the deployment targets (production, staging, ...)
|
40
|
+
|
41
|
+
This is the configuration capistrano uses when you invoke `cap TARGET deploy`
|
42
|
+
|
43
|
+
TODO: ask for server name on `railman new APP_NAME`
|
44
|
+
|
45
|
+
## config/environments/development.rb
|
46
|
+
|
47
|
+
Add config.action_mailer.default_url_options and letter_opener (todo)
|
48
|
+
|
49
|
+
## config/environments/production.rb
|
50
|
+
|
51
|
+
Add smtp settings and exception notification settings
|
52
|
+
|
53
|
+
## config/environments/test.rb
|
54
|
+
|
55
|
+
Add config.action_mailer.default_url_options
|
56
|
+
|
57
|
+
## config/locales/readme.txt
|
58
|
+
|
59
|
+
Describes how to add additional languages
|
60
|
+
|
61
|
+
## config/server/nginx.conf
|
62
|
+
|
63
|
+
Nginx configuration. Capistrano links this file in the nginx conf.
|
64
|
+
|
65
|
+
## config/server/logrotate.conf
|
66
|
+
|
67
|
+
Logrotate configuration. Capistrano links this file ...
|
68
|
+
|
69
|
+
## config/server/letsencrypt.conf
|
70
|
+
|
71
|
+
Let's Encrypt configuration file that can be used to automatically generate Let's Encrypt SSL certificates.
|
72
|
+
|
73
|
+
## config/database.yml
|
74
|
+
|
75
|
+
Use postgres.
|
76
|
+
Use database user and password from .env
|
77
|
+
|
78
|
+
## config/secrets.yml
|
79
|
+
|
80
|
+
Use SECRET_TOKEN from .env
|
81
|
+
|
data/lib/railman/cli.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require '
|
2
|
+
require 'creategem'
|
3
3
|
|
4
4
|
module Railman
|
5
5
|
class CLI < Thor
|
6
6
|
include Thor::Actions
|
7
|
+
include Creategem::Git
|
7
8
|
|
8
9
|
attr_accessor :app_name
|
9
10
|
|
@@ -17,11 +18,25 @@ module Railman
|
|
17
18
|
say "Create a new rails application named: #{app_name}", :green
|
18
19
|
@app_name = app_name
|
19
20
|
@class_name = Thor::Util.camel_case(app_name)
|
21
|
+
@admin_email = ask("What is the adminitrator email address?")
|
22
|
+
@domain = ask("What is the url of the application (without http and www)?")
|
23
|
+
if yes?("Do you want me to configure www.#{@domain} domain to be redirected to #{@domain}? (y/n)")
|
24
|
+
@www_domain = "www.#{@domain}"
|
25
|
+
@domains = [@domain, @www_domain]
|
26
|
+
else
|
27
|
+
@www_domain = nil
|
28
|
+
@domains = [@domain]
|
29
|
+
end
|
30
|
+
@server = ask("What is the name of the production server?")
|
20
31
|
directory "rails_app", app_name
|
32
|
+
repository = Creategem::Repository.new(vendor: :bitbucket,
|
33
|
+
user: git_repository_user_name(:bitbucket),
|
34
|
+
name: app_name,
|
35
|
+
gem_server_url: gem_server_url(:bitbucket))
|
21
36
|
Dir.chdir app_name do
|
22
|
-
|
37
|
+
create_local_git_repository
|
23
38
|
run "bundle install"
|
24
|
-
|
39
|
+
create_remote_git_repository(repository) if yes?("Do you want me to create bitbucket repository named #{app_name}? (y/n)")
|
25
40
|
end
|
26
41
|
say "The rails application '#{app_name}' was successfully created.", :green
|
27
42
|
end
|
data/lib/railman/version.rb
CHANGED
data/railman.gemspec
CHANGED
@@ -23,6 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "minitest-reporters", "~> 1.1"
|
24
24
|
spec.add_development_dependency "gem-release", "~> 0.7"
|
25
25
|
spec.add_development_dependency "geminabox", "~> 0.13"
|
26
|
+
spec.add_development_dependency "coveralls"
|
26
27
|
|
27
28
|
spec.add_dependency "thor", "~> 0.19"
|
29
|
+
spec.add_dependency "creategem", "~> 0.2"
|
28
30
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Put server-specific environment variables here
|
2
|
+
# .env is loaded by the dotenv gem on startup
|
3
|
+
# Don't commit this file to Git !!! Copy from .env.example and modify for each machine
|
4
|
+
|
5
|
+
# Application settings
|
6
|
+
APP_NAME = '<%= app_name %>'
|
7
|
+
|
8
|
+
|
9
|
+
# Database settings
|
10
|
+
DB_USER = 'user'
|
11
|
+
DB_PASSWORD = 'password'
|
12
|
+
|
13
|
+
|
14
|
+
# Session secret - generate with: rake secret
|
15
|
+
SECRET_TOKEN = 'todo: generate with: rake secret'
|
16
|
+
|
17
|
+
|
18
|
+
# SMTP server settings
|
19
|
+
SMTP_SERVER = 'mail.<%= @domain %>'
|
20
|
+
SMTP_USER = 'server@<%= @domain %>'
|
21
|
+
SMTP_PASSWORD = '*****'
|
22
|
+
SMTP_DOMAIN = '<%= @domain %>'
|
23
|
+
SMTP_DEFAULT_URL = '<%= @domain %>'
|
24
|
+
|
25
|
+
# Where to send exceptions and other admin emails
|
26
|
+
ADMIN_EMAIL = '<%= @admin_email %>'
|
27
|
+
|
28
|
+
# Exception notification settings
|
29
|
+
EXCEPTION_NOTIFICATION_EMAIL_PREFIX = '[<%= @class_name %>] '
|
30
|
+
EXCEPTION_NOTIFICATION_SENDER = 'server@<%= @domain %>'
|
31
|
+
|
32
|
+
# Unicorn settings
|
33
|
+
UNICORN_PORT = 3000
|
34
|
+
# UNICORN_SOCK = '/tmp/unicorn.<%= app_name %>.sock'
|
35
|
+
UNICORN_WORKERS = 2
|
36
|
+
UNICORN_TIMEOUT = 60
|
37
|
+
|
38
|
+
|
39
|
+
# Rails environment
|
40
|
+
RAILS_ENV = 'development'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Eye configuration file (https://github.com/kostya/eye)
|
2
|
+
# Load with: 'eye l Eyefile'
|
3
|
+
# Watch processes: 'eye w'
|
4
|
+
# Stop all processes: 'eye stop <%= app_name %>'
|
5
|
+
# Start all processes: 'eye start <%= app_name %>'
|
6
|
+
# Restart unicorn: 'eye restart <%= app_name %>:unicorn'
|
7
|
+
|
8
|
+
APP_ROOT = File.expand_path('..', __FILE__)
|
9
|
+
|
10
|
+
Eye.load '.env'
|
11
|
+
|
12
|
+
Eye.config do
|
13
|
+
logger File.join APP_ROOT, 'log/eye.log'
|
14
|
+
end
|
15
|
+
|
16
|
+
Eye.application APP_NAME do
|
17
|
+
working_dir APP_ROOT
|
18
|
+
auto_start false
|
19
|
+
notify :errors
|
20
|
+
|
21
|
+
trigger :flapping, times: 3, within: 1.minute, retry_in: 1.minutes, retry_times: 1
|
22
|
+
|
23
|
+
process :unicorn do
|
24
|
+
unicorn_env = { 'RAILS_ENV' => RAILS_ENV, 'UNICORN_WORKERS' => UNICORN_WORKERS }
|
25
|
+
unicorn_env['UNICORN_PORT'] = UNICORN_PORT if defined?(UNICORN_PORT)
|
26
|
+
unicorn_env['UNICORN_SOCK'] = UNICORN_SOCK if defined?(UNICORN_SOCK)
|
27
|
+
env unicorn_env
|
28
|
+
start_command "./bin/unicorn -c #{APP_ROOT}/config/unicorn.rb -E #{RAILS_ENV} -D"
|
29
|
+
pid_file './tmp/pids/unicorn.pid'
|
30
|
+
stop_signals [:QUIT, 10.seconds, :KILL]
|
31
|
+
restart_command 'kill -USR2 {PID}'
|
32
|
+
|
33
|
+
start_timeout 100.seconds
|
34
|
+
restart_grace 30.seconds
|
35
|
+
|
36
|
+
monitor_children do
|
37
|
+
stop_command 'kill -QUIT {PID}'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/templates/rails_app/Gemfile
CHANGED
@@ -1,36 +1,30 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
+
gem 'dotenv-rails', '2.1.1', require: 'dotenv/rails-now' # load ENV from .env
|
3
4
|
|
4
|
-
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
5
5
|
gem 'rails', '4.2.6'
|
6
|
-
|
7
|
-
|
8
|
-
# Use SCSS for stylesheets
|
6
|
+
gem 'pg', '0.18.2'
|
7
|
+
|
9
8
|
gem 'sass-rails', '~> 5.0'
|
10
|
-
# Use Uglifier as compressor for JavaScript assets
|
11
9
|
gem 'uglifier', '>= 1.3.0'
|
12
|
-
# Use CoffeeScript for .coffee assets and views
|
13
10
|
gem 'coffee-rails', '~> 4.1.0'
|
14
|
-
# See https://github.com/rails/execjs#readme for more supported runtimes
|
15
|
-
# gem 'therubyracer', platforms: :ruby
|
16
|
-
|
17
|
-
# Use jquery as the JavaScript library
|
18
11
|
gem 'jquery-rails'
|
19
|
-
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
20
12
|
gem 'turbolinks'
|
13
|
+
|
21
14
|
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
22
15
|
gem 'jbuilder', '~> 2.0'
|
23
|
-
# bundle exec rake doc:rails generates the API under doc/api.
|
24
|
-
gem 'sdoc', '~> 0.4.0', group: :doc
|
25
16
|
|
26
17
|
# Use ActiveModel has_secure_password
|
27
18
|
# gem 'bcrypt', '~> 3.1.7'
|
28
19
|
|
29
|
-
#
|
30
|
-
|
20
|
+
gem 'unicorn', '4.8.2' # use unicorn as production server
|
21
|
+
gem 'unicorn-rails', '1.1.0' # use unicorn as local server
|
31
22
|
|
32
|
-
#
|
33
|
-
|
23
|
+
# capistrano deployment
|
24
|
+
gem 'capistrano', '3.1.0'
|
25
|
+
gem 'capistrano-rails', '1.1.1'
|
26
|
+
gem 'capistrano-rbenv', '2.0.2'
|
27
|
+
gem 'capistrano-bundler', '1.1.2'
|
34
28
|
|
35
29
|
group :development, :test do
|
36
30
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
@@ -45,3 +39,8 @@ group :development do
|
|
45
39
|
gem 'spring'
|
46
40
|
end
|
47
41
|
|
42
|
+
gem 'exception_notification', '4.1.2' # exception notification per email
|
43
|
+
|
44
|
+
local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
|
45
|
+
eval_gemfile(local_gemfile) if File.exists?(local_gemfile)
|
46
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# TODO
|
2
|
+
|
3
|
+
This file describes what you have to customize after you create a new rails application with railman
|
4
|
+
|
5
|
+
## .env.example and .env
|
6
|
+
|
7
|
+
Copy .env.example, name the copy .env, and modify .env for your local development environment.
|
8
|
+
|
9
|
+
.env is gitignored. This is intended. You should create a local .env file on every server your deploy your rails application to, and modify the settings for that server.
|
10
|
+
|
11
|
+
Create secret token with `rake secret` and copy the secret to your .env file.
|
12
|
+
|
13
|
+
Try to keep all the application/server/environment specific settings, as well as all passwords here, as .env is not commited to git and exists only on a server or local user machine. This will also make future rails upgrades and changes in the configuration files less painful.
|
14
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
development:
|
2
|
+
adapter: postgresql
|
3
|
+
encoding: unicode
|
4
|
+
port: 5432
|
5
|
+
host: localhost
|
6
|
+
database: <%= app_name %>_development
|
7
|
+
username: <%= ENV['DB_USER'] %>
|
8
|
+
password: <%= ENV['DB_PASSWORD'] %>
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
test:
|
13
|
+
adapter: postgresql
|
14
|
+
encoding: unicode
|
15
|
+
port: 5432
|
16
|
+
host: localhost
|
17
|
+
database: <%= app_name %>_test
|
18
|
+
username: <%= ENV['DB_USER'] %>
|
19
|
+
password: <%= ENV['DB_PASSWORD'] %>
|
20
|
+
pool: 5
|
21
|
+
timeout: 5000
|
22
|
+
|
23
|
+
production:
|
24
|
+
adapter: postgresql
|
25
|
+
encoding: unicode
|
26
|
+
port: 5432
|
27
|
+
host: localhost
|
28
|
+
database: <%= app_name %>_production
|
29
|
+
username: <%= ENV['DB_USER'] %>
|
30
|
+
password: <%= ENV['DB_PASSWORD'] %>
|
31
|
+
pool: 15
|
32
|
+
timeout: 5000
|
@@ -38,4 +38,8 @@ Rails.application.configure do
|
|
38
38
|
|
39
39
|
# Raises error for missing translations
|
40
40
|
# config.action_view.raise_on_missing_translations = true
|
41
|
+
|
42
|
+
# TODO config.action_mailer.delivery_method = :letter_opener
|
43
|
+
|
44
|
+
config.action_mailer.default_url_options = { host: 'http://localhost:3000' }
|
41
45
|
end
|
@@ -11,7 +11,7 @@ Rails.application.configure do
|
|
11
11
|
config.eager_load = true
|
12
12
|
|
13
13
|
# Full error reports are disabled and caching is turned on.
|
14
|
-
config.consider_all_requests_local
|
14
|
+
config.consider_all_requests_local = false
|
15
15
|
config.action_controller.perform_caching = true
|
16
16
|
|
17
17
|
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
@@ -76,4 +76,22 @@ Rails.application.configure do
|
|
76
76
|
|
77
77
|
# Do not dump schema after migrations.
|
78
78
|
config.active_record.dump_schema_after_migration = false
|
79
|
+
|
80
|
+
config.action_mailer.delivery_method = :smtp
|
81
|
+
config.action_mailer.smtp_settings = {
|
82
|
+
address: ENV['SMTP_SERVER'],
|
83
|
+
user_name: ENV['SMTP_USER'],
|
84
|
+
password: ENV['SMTP_PASSWORD'],
|
85
|
+
domain: ENV['SMTP_DOMAIN'],
|
86
|
+
authentication: 'login',
|
87
|
+
enable_starttls_auto: true
|
88
|
+
}
|
89
|
+
config.action_mailer.default_url_options = { host: ENV['SMTP_DEFAULT_URL'] }
|
90
|
+
|
91
|
+
config.middleware.use ExceptionNotification::Rack,
|
92
|
+
email: {
|
93
|
+
email_prefix: ENV['EXCEPTION_NOTIFICATION_EMAIL_PREFIX'],
|
94
|
+
sender_address: ENV['EXCEPTION_NOTIFICATION_SENDER'],
|
95
|
+
exception_recipients: ENV['ADMIN_EMAIL']
|
96
|
+
}
|
79
97
|
end
|
@@ -11,12 +11,12 @@
|
|
11
11
|
# if you're sharing your code publicly.
|
12
12
|
|
13
13
|
development:
|
14
|
-
secret_key_base:
|
14
|
+
secret_key_base: <%= ENV["SECRET_TOKEN"] %>
|
15
15
|
|
16
16
|
test:
|
17
|
-
secret_key_base:
|
17
|
+
secret_key_base: <%= ENV["SECRET_TOKEN"] %>
|
18
18
|
|
19
19
|
# Do not keep production secrets in the repository,
|
20
20
|
# instead read values from the environment.
|
21
21
|
production:
|
22
|
-
secret_key_base: <%= ENV["
|
22
|
+
secret_key_base: <%= ENV["SECRET_TOKEN"] %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Use a 4096 bit RSA key instead of 2048
|
2
|
+
rsa-key-size = 4096
|
3
|
+
|
4
|
+
# this address will receive renewal reminders, IIRC
|
5
|
+
email = <%= @admin_email %>
|
6
|
+
|
7
|
+
# Generate certificates for the specified domains
|
8
|
+
domains = <%= @domains.join(',') %>
|
9
|
+
|
10
|
+
# turn off the ncurses UI, we want this to be run as a cronjob
|
11
|
+
text = True
|
12
|
+
|
13
|
+
# authenticate by placing a file in the webroot (under .well-known/acme-challenge/) and then letting LE fetch it
|
14
|
+
webroot-path = /home/deploy/apps/<%= app_name %>
|
@@ -0,0 +1,70 @@
|
|
1
|
+
upstream <%= app_name %> {
|
2
|
+
server unix:/tmp/unicorn.<%= app_name %>.sock fail_timeout=0;
|
3
|
+
}
|
4
|
+
|
5
|
+
server {
|
6
|
+
listen 443 ssl;
|
7
|
+
server_name <%= @domain %>;
|
8
|
+
|
9
|
+
index index.html;
|
10
|
+
root /home/deploy/apps/<%= app_name %>/public;
|
11
|
+
try_files $uri/index.html $uri @app;
|
12
|
+
|
13
|
+
location @app {
|
14
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
15
|
+
# enable this if you forward HTTPS traffic to unicorn,
|
16
|
+
# this helps Rack set the proper URL scheme for doing redirects:
|
17
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
18
|
+
|
19
|
+
proxy_set_header Host $http_host;
|
20
|
+
proxy_redirect off;
|
21
|
+
proxy_pass http://<%= app_name %>;
|
22
|
+
}
|
23
|
+
|
24
|
+
client_max_body_size 100m;
|
25
|
+
|
26
|
+
error_page 500 502 503 504 /500.html;
|
27
|
+
|
28
|
+
location ~ ^/assets/ {
|
29
|
+
expires 1y;
|
30
|
+
add_header Cache-Control public;
|
31
|
+
add_header ETag "";
|
32
|
+
|
33
|
+
if ($request_filename ~* ^.*?\.(eot)|(ttf)|(woff)|(svg)|(otf)$){
|
34
|
+
add_header Access-Control-Allow-Origin *;
|
35
|
+
}
|
36
|
+
break;
|
37
|
+
}
|
38
|
+
|
39
|
+
location ~ ^/(assets)/ {
|
40
|
+
root /home/deploy/apps/<%= app_name %>/public;
|
41
|
+
gzip_static on; # to serve pre-gzipped version
|
42
|
+
expires max;
|
43
|
+
add_header Cache-Control public;
|
44
|
+
}
|
45
|
+
|
46
|
+
# Let's Encrypt certificates
|
47
|
+
ssl_certificate /etc/letsencrypt/live/<%= @domain %>/fullchain.pem;
|
48
|
+
ssl_certificate_key /etc/letsencrypt/live/<%= @domain %>/privkey.pem;
|
49
|
+
|
50
|
+
location /home/deploy/apps/<%= app_name %>/public/.well-known {
|
51
|
+
allow all;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
server {
|
57
|
+
listen 80;
|
58
|
+
server_name <%= @domains.join(' ') %>;
|
59
|
+
return 301 https://<%= @domain %>$request_uri;
|
60
|
+
}
|
61
|
+
|
62
|
+
server {
|
63
|
+
listen 443 ssl;
|
64
|
+
server_name <%= @www_domain %>;
|
65
|
+
return 301 $scheme://<%= @domain %>$request_uri;
|
66
|
+
|
67
|
+
# Let's Encrypt certificates
|
68
|
+
ssl_certificate /etc/letsencrypt/live/<%= @domain %>/fullchain.pem;
|
69
|
+
ssl_certificate_key /etc/letsencrypt/live/<%= @domain %>/privkey.pem;
|
70
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Unicorn configuration
|
2
|
+
|
3
|
+
APP_ROOT = File.expand_path('../..', __FILE__)
|
4
|
+
|
5
|
+
require 'dotenv'
|
6
|
+
Dotenv.load
|
7
|
+
|
8
|
+
timeout Integer(ENV['UNICORN_TIMEOUT'])
|
9
|
+
if ENV['UNICORN_SOCK'] # behind nginx
|
10
|
+
listen ENV['UNICORN_SOCK']
|
11
|
+
else
|
12
|
+
listen Integer(ENV['UNICORN_PORT'])
|
13
|
+
end
|
14
|
+
worker_processes Integer(ENV['UNICORN_WORKERS'])
|
15
|
+
working_directory APP_ROOT
|
16
|
+
pid "#{APP_ROOT}/tmp/pids/unicorn.pid"
|
17
|
+
|
18
|
+
stderr_path "#{APP_ROOT}/log/unicorn.log"
|
19
|
+
stdout_path "/#{APP_ROOT}/log/unicorn.log"
|
20
|
+
|
21
|
+
# load the application in the master process before forking worker processes
|
22
|
+
preload_app true
|
23
|
+
|
24
|
+
GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true
|
25
|
+
|
26
|
+
before_fork do |server, worker|
|
27
|
+
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
|
28
|
+
|
29
|
+
# When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
|
30
|
+
# immediately start loading up a new version of itself (loaded with a new
|
31
|
+
# version of our app). When this new Unicorn is completely loaded
|
32
|
+
# it will begin spawning workers. The first worker spawned will check to
|
33
|
+
# see if an .oldbin pidfile exists. If so, this means we've just booted up
|
34
|
+
# a new Unicorn and need to tell the old one that it can now die. To do so
|
35
|
+
# we send it a QUIT.
|
36
|
+
#
|
37
|
+
# Using this method we get 0 downtime deploys.
|
38
|
+
old_pid = "#{APP_ROOT}/tmp/pids/unicorn.pid.oldbin"
|
39
|
+
if File.exists?(old_pid) && server.pid != old_pid
|
40
|
+
begin
|
41
|
+
Process.kill("QUIT", File.read(old_pid).to_i)
|
42
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
43
|
+
# someone else did our job for us
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
after_fork do |server, worker|
|
49
|
+
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
|
50
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Jancev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0.13'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: thor
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +122,20 @@ dependencies:
|
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0.19'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: creategem
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.2'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.2'
|
111
139
|
description: Rails application generator that speeds up develoment of new rails applications
|
112
140
|
email:
|
113
141
|
- igor@masterybits.com
|
@@ -119,6 +147,7 @@ files:
|
|
119
147
|
- ".gitignore"
|
120
148
|
- ".ruby-version"
|
121
149
|
- ".travis.yml"
|
150
|
+
- CUSTOMIZATION.md
|
122
151
|
- Gemfile
|
123
152
|
- LICENCE.txt
|
124
153
|
- README.md
|
@@ -130,11 +159,15 @@ files:
|
|
130
159
|
- lib/railman/cli.rb
|
131
160
|
- lib/railman/version.rb
|
132
161
|
- railman.gemspec
|
162
|
+
- templates/rails_app/.env.example.tt
|
163
|
+
- templates/rails_app/.envrc
|
133
164
|
- templates/rails_app/.gitignore
|
134
165
|
- templates/rails_app/.ruby-version
|
166
|
+
- templates/rails_app/Eyefile.tt
|
135
167
|
- templates/rails_app/Gemfile
|
136
168
|
- templates/rails_app/README.rdoc
|
137
169
|
- templates/rails_app/Rakefile
|
170
|
+
- templates/rails_app/TODO.md
|
138
171
|
- templates/rails_app/app/assets/images/.keep
|
139
172
|
- templates/rails_app/app/assets/javascripts/application.js
|
140
173
|
- templates/rails_app/app/assets/stylesheets/application.css
|
@@ -153,7 +186,8 @@ files:
|
|
153
186
|
- templates/rails_app/config.ru
|
154
187
|
- templates/rails_app/config/application.rb.tt
|
155
188
|
- templates/rails_app/config/boot.rb
|
156
|
-
- templates/rails_app/config/database.yml
|
189
|
+
- templates/rails_app/config/database.yml.tt
|
190
|
+
- templates/rails_app/config/deploy/production.rb.tt
|
157
191
|
- templates/rails_app/config/environment.rb
|
158
192
|
- templates/rails_app/config/environments/development.rb
|
159
193
|
- templates/rails_app/config/environments/production.rb
|
@@ -167,8 +201,13 @@ files:
|
|
167
201
|
- templates/rails_app/config/initializers/session_store.rb.tt
|
168
202
|
- templates/rails_app/config/initializers/wrap_parameters.rb
|
169
203
|
- templates/rails_app/config/locales/en.yml
|
204
|
+
- templates/rails_app/config/locales/readme.txt
|
170
205
|
- templates/rails_app/config/routes.rb
|
171
206
|
- templates/rails_app/config/secrets.yml
|
207
|
+
- templates/rails_app/config/server/letsencrypt.conf.tt
|
208
|
+
- templates/rails_app/config/server/logrotate.conf.tt
|
209
|
+
- templates/rails_app/config/server/nginx.conf.tt
|
210
|
+
- templates/rails_app/config/unicorn.rb
|
172
211
|
- templates/rails_app/db/seeds.rb
|
173
212
|
- templates/rails_app/lib/assets/.keep
|
174
213
|
- templates/rails_app/lib/tasks/.keep
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# SQLite version 3.x
|
2
|
-
# gem install sqlite3
|
3
|
-
#
|
4
|
-
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
-
# gem 'sqlite3'
|
6
|
-
#
|
7
|
-
default: &default
|
8
|
-
adapter: sqlite3
|
9
|
-
pool: 5
|
10
|
-
timeout: 5000
|
11
|
-
|
12
|
-
development:
|
13
|
-
<<: *default
|
14
|
-
database: db/development.sqlite3
|
15
|
-
|
16
|
-
# Warning: The database defined as "test" will be erased and
|
17
|
-
# re-generated from your development database when you run "rake".
|
18
|
-
# Do not set this db to the same as development or production.
|
19
|
-
test:
|
20
|
-
<<: *default
|
21
|
-
database: db/test.sqlite3
|
22
|
-
|
23
|
-
production:
|
24
|
-
<<: *default
|
25
|
-
database: db/production.sqlite3
|