trireme 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/trireme/app_builder.rb +17 -7
- data/lib/trireme/generators/app_generator.rb +1 -2
- data/lib/trireme/templates/app/helpers/utility_helper.rb +3 -1
- data/lib/trireme/templates/config/deploy.rb.erb +55 -41
- data/lib/trireme/templates/config/deploy/production.rb.erb +15 -0
- data/lib/trireme/templates/config/deploy/staging.rb.erb +16 -0
- data/lib/trireme/templates/{config/recipes → lib/mina}/check.rb +1 -4
- data/lib/trireme/templates/lib/mina/db.rb.erb +10 -0
- data/lib/trireme/templates/lib/mina/defaults.rb +35 -0
- data/lib/trireme/templates/lib/mina/irc.rb.erb +22 -0
- data/lib/trireme/templates/lib/mina/log.rb.erb +21 -0
- data/lib/trireme/templates/lib/mina/logrotate.rb +7 -0
- data/lib/trireme/templates/lib/mina/nginx.rb +23 -0
- data/lib/trireme/templates/lib/mina/postgresql.rb +37 -0
- data/lib/trireme/templates/{config/recipes → lib/mina}/templates/logrotate.erb +1 -1
- data/lib/trireme/templates/{config/recipes → lib/mina}/templates/nginx_unicorn.erb +8 -8
- data/lib/trireme/templates/{config/recipes → lib/mina}/templates/postgresql.yml.erb +0 -0
- data/lib/trireme/templates/{config/recipes → lib/mina}/templates/unicorn.rb.erb +2 -2
- data/lib/trireme/templates/{config/recipes → lib/mina}/templates/unicorn_init.erb +2 -2
- data/lib/trireme/templates/lib/mina/unicorn.rb +21 -0
- data/lib/trireme/templates/lib/mina/utility.rb +44 -0
- data/lib/trireme/templates/lib/templates/erb/scaffold/edit.html.erb +3 -3
- data/lib/trireme/templates/lib/templates/erb/scaffold/index.html.erb +7 -3
- data/lib/trireme/templates/lib/templates/erb/scaffold/new.html.erb +2 -2
- data/lib/trireme/templates/lib/templates/erb/scaffold/show.html.erb +2 -2
- data/lib/trireme/version.rb +1 -1
- metadata +19 -18
- data/lib/trireme/templates/Capfile +0 -4
- data/lib/trireme/templates/config/deploy/production.rb +0 -17
- data/lib/trireme/templates/config/deploy/staging.rb +0 -8
- data/lib/trireme/templates/config/recipes/base.rb +0 -8
- data/lib/trireme/templates/config/recipes/log.rb +0 -6
- data/lib/trireme/templates/config/recipes/logrotate.rb +0 -8
- data/lib/trireme/templates/config/recipes/nginx.rb +0 -17
- data/lib/trireme/templates/config/recipes/postgresql.rb +0 -32
- data/lib/trireme/templates/config/recipes/scripts/sql_functions.sql +0 -23
- data/lib/trireme/templates/config/recipes/unicorn.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61b2fc070bbe41b72043ad7659dc30e983b51e5a
|
4
|
+
data.tar.gz: e0fd5ff48fd6b38f1101137430628dfef3f0ac50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12bdbb5ac2a2e0a8f2b1dc3be7a92b46f7e8b988d38f667681dabaa0b33d8e439849091668647e7d3d62f0ef70c48680378e38a25fb4a3c655d6ad1bf899993a
|
7
|
+
data.tar.gz: 02df4ff322b341f89be889740b344b98e9ead096b98fcc6a82bd4ab6ea29da052e0ff9f56660f614436e58a6521900af24ab7bd83a44cf70d8373f32be1da5e6
|
data/lib/trireme/app_builder.rb
CHANGED
@@ -5,7 +5,7 @@ module Trireme
|
|
5
5
|
include Trireme::Actions
|
6
6
|
|
7
7
|
def add_additional_gems
|
8
|
-
if yes?
|
8
|
+
if config_settings[:gems].include?('carrierwave') || yes?("Add carrierwave for file uploading?")
|
9
9
|
@generator.gem 'carrierwave'
|
10
10
|
@generator.gem 'mini_magick'
|
11
11
|
end
|
@@ -126,7 +126,7 @@ module Trireme
|
|
126
126
|
"config.action_mailer_delivery_method = :smtp\n\tconfig.action_mailer.smtp_settings = #{format_config(config_settings[:action_mailer][:smtp_settings])}"
|
127
127
|
end
|
128
128
|
|
129
|
-
def
|
129
|
+
def setup_deploy
|
130
130
|
if @domain_base && @server_ip
|
131
131
|
opts = { domain_base: @domain_base, server_ip: @server_ip, force: true }
|
132
132
|
else
|
@@ -134,10 +134,20 @@ module Trireme
|
|
134
134
|
opts[:server_ip] = ask("Server IP:")
|
135
135
|
opts[:force] = true
|
136
136
|
end
|
137
|
-
|
137
|
+
puts @config.to_yaml
|
138
|
+
deploy_opts = opts.merge({config_settings: config_settings})
|
139
|
+
template "config/deploy.rb.erb", "config/deploy.rb", deploy_opts
|
138
140
|
directory "config/deploy"
|
139
|
-
|
140
|
-
|
141
|
+
%w[staging.rb production.rb].each { |f| template "config/deploy/#{f}.erb", "config/deploy/#{f}", deploy_opts }
|
142
|
+
|
143
|
+
directory "lib/mina"
|
144
|
+
|
145
|
+
Dir["#{File.expand_path('../../trireme/templates/lib/mina/', __FILE__)}/*.erb"].each do |file|
|
146
|
+
file = file.split('/').last
|
147
|
+
template "lib/mina/#{file}", "lib/mina/#{file.gsub('.erb', '')}", deploy_opts
|
148
|
+
puts "lib/mina/#{file}", "lib/mina/#{file.gsub('.erb', '')}"
|
149
|
+
end
|
150
|
+
run 'rm lib/mina/*.erb'
|
141
151
|
end
|
142
152
|
|
143
153
|
def setup_console
|
@@ -146,7 +156,7 @@ module Trireme
|
|
146
156
|
|
147
157
|
def setup_devise
|
148
158
|
if config_settings[:devise][:include] || yes?("Add Devise?")
|
149
|
-
devise_model = ask("Devise model (default: #{config_settings[:devise][:model]}):").underscore
|
159
|
+
devise_model = ask("Devise model (default: #{config_settings[:devise][:model]}):").underscore unless config_settings[:devise][:force_model]
|
150
160
|
devise_model = config_settings[:devise][:model] if devise_model.blank?
|
151
161
|
@generator.gem 'devise'
|
152
162
|
run 'bundle install'
|
@@ -170,7 +180,7 @@ module Trireme
|
|
170
180
|
if config_settings[:exception_notification][:irc]
|
171
181
|
config_settings[:exception_notification][:irc][:prefix] = "[#{app_name.titleize} Production]"
|
172
182
|
en_config << ",\n\t\t" if en_config[/}\Z/]
|
173
|
-
en_config << ":irc => #{format_config(config_settings[:exception_notification][:irc], 2)}"
|
183
|
+
en_config << ":irc => #{format_config(config_settings[:exception_notification][:irc].merge(config_settings[:irc]), 2)}"
|
174
184
|
end
|
175
185
|
configure_environment "production", en_config
|
176
186
|
end
|
@@ -3,7 +3,6 @@ require 'rails/generators/rails/app/app_generator'
|
|
3
3
|
|
4
4
|
module Trireme
|
5
5
|
class AppGenerator < Rails::Generators::AppGenerator
|
6
|
-
class_option :database, type: :string, aliases: '-d', default: 'sqlite3', desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
7
6
|
class_option :config_file, type: :string, aliases: '-c', desc: "Include yaml configuration file"
|
8
7
|
|
9
8
|
def finish_template
|
@@ -147,7 +146,7 @@ module Trireme
|
|
147
146
|
build :get_server_options
|
148
147
|
|
149
148
|
# Add deploy configuration and recipes
|
150
|
-
build :
|
149
|
+
build :setup_deploy
|
151
150
|
end
|
152
151
|
|
153
152
|
def setup_git
|
@@ -15,14 +15,16 @@ module UtilityHelper
|
|
15
15
|
html_tag << '<i class="fa fa-circle fa-stack-2x"></i>'
|
16
16
|
html_tag << "<i class=\"fa fa-#{name} fa-stack-1x fa-inverse\"></i>"
|
17
17
|
html_tag << '</span>'
|
18
|
+
html_tag << '</div>' if opts[:wrapper]
|
18
19
|
else
|
19
20
|
html_tag << "<i class=\"fa fa-#{name}"
|
20
21
|
html_tag << " #{opts[:additional]}" if opts.has_key? :additional
|
21
22
|
html_tag << " fa-border" if opts[:border]
|
22
23
|
html_tag << " fa-#{opts[:size]}" if opts[:size]
|
23
24
|
html_tag << '"></i>'
|
24
|
-
html_tag << '</div>' if opts[:wrapper]
|
25
25
|
end
|
26
|
+
html_tag << " #{opts[:text]}" if opts[:text]
|
27
|
+
html_tag << '</div>' if opts[:wrapper]
|
26
28
|
html_tag.html_safe
|
27
29
|
end
|
28
30
|
|
@@ -1,41 +1,55 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
require
|
14
|
-
require
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
load
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
set :
|
27
|
-
|
28
|
-
set :
|
29
|
-
set :
|
30
|
-
set :
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
1
|
+
$:.unshift './lib'
|
2
|
+
|
3
|
+
require 'mina/bundler'
|
4
|
+
require 'mina/rails'
|
5
|
+
require 'mina/git'
|
6
|
+
|
7
|
+
require 'mina/defaults'
|
8
|
+
require 'mina/utility'
|
9
|
+
require 'mina/nginx'
|
10
|
+
require 'mina/unicorn'
|
11
|
+
require 'mina/postgresql'
|
12
|
+
require 'mina/logrotate'
|
13
|
+
require 'mina/log'
|
14
|
+
require 'mina/check'
|
15
|
+
require 'mina/irc'
|
16
|
+
require 'mina/db'
|
17
|
+
|
18
|
+
# Load environments from config/deploy
|
19
|
+
Dir['config/deploy/*.rb'].each { |f| load f }
|
20
|
+
|
21
|
+
###########################################################################
|
22
|
+
# Common settings for all servers
|
23
|
+
###########################################################################
|
24
|
+
|
25
|
+
set :application, "<%= app_name %>"
|
26
|
+
set :application_name, "<%= app_name.titleize %>"
|
27
|
+
set :domain_name, "<%= config[:domain_base] %>"
|
28
|
+
set :keep_releases, 5
|
29
|
+
set :repository, "<%= config[:config_settings][:git][:url] %>#{app_name}.git"
|
30
|
+
set :default_server, 'staging'
|
31
|
+
|
32
|
+
###########################################################################
|
33
|
+
|
34
|
+
set :server, ENV['to'] || default_server
|
35
|
+
invoke :"env:#{server}"
|
36
|
+
|
37
|
+
desc "Deploys the current version to the server."
|
38
|
+
task :deploy => :environment do
|
39
|
+
deploy do
|
40
|
+
invoke :'check:revision'
|
41
|
+
invoke :'git:clone'
|
42
|
+
invoke :'deploy:link_shared_paths'
|
43
|
+
invoke :'bundle:install'
|
44
|
+
invoke :'rails:db_migrate'
|
45
|
+
invoke :'rails:assets_precompile'
|
46
|
+
|
47
|
+
to :launch do
|
48
|
+
invoke :'unicorn:stop'
|
49
|
+
queue %{sleep 3}
|
50
|
+
invoke :'unicorn:start'
|
51
|
+
end
|
52
|
+
|
53
|
+
<%= "invoke :'irc:announce_deploy'" if config[:config_settings][:mina][:irc] %>
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
namespace :env do
|
2
|
+
task :production => [:environment] do
|
3
|
+
set :server_ip, '<%= config[:server_ip] || '123.123.123.123' %>'
|
4
|
+
set :domain, server_ip
|
5
|
+
set :deploy_server, 'production'
|
6
|
+
set :rails_env, 'production'
|
7
|
+
set :branch, 'master'
|
8
|
+
set :rewrite_www, true
|
9
|
+
set :include_ssl, false
|
10
|
+
set :default_host, true
|
11
|
+
set :unicorn_workers, 1
|
12
|
+
|
13
|
+
invoke :defaults
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
namespace :env do
|
2
|
+
task :staging => [:environment] do
|
3
|
+
set :server_ip, '<%= config[:server_ip] || '123.123.123.123' %>'
|
4
|
+
set :domain, server_ip
|
5
|
+
set :deploy_server, 'staging'
|
6
|
+
set :rails_env, 'staging'
|
7
|
+
set :branch, 'staging'
|
8
|
+
set :rewrite_www, false
|
9
|
+
set :include_ssl, false
|
10
|
+
set :default_host, false
|
11
|
+
set :unicorn_workers, 1
|
12
|
+
|
13
|
+
invoke :defaults
|
14
|
+
set :domain_name, "demo.#{domain_name}"
|
15
|
+
end
|
16
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
namespace :check do
|
2
2
|
desc "Make sure local git is in sync with remote."
|
3
|
-
task :revision
|
3
|
+
task :revision do
|
4
4
|
current_repository = "origin"
|
5
5
|
unless (`git rev-parse HEAD` == `git rev-parse #{current_repository}/#{branch}`)
|
6
6
|
puts "WARNING: HEAD is not the same as #{current_repository}/#{branch}"
|
@@ -8,7 +8,4 @@ namespace :check do
|
|
8
8
|
exit
|
9
9
|
end
|
10
10
|
end
|
11
|
-
before "deploy", "check:revision"
|
12
|
-
before "deploy:migrations", "check:revision"
|
13
|
-
before "deploy:cold", "check:revision"
|
14
11
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
task :defaults do
|
2
|
+
set_default :user, 'deployer'
|
3
|
+
set_default :group, user
|
4
|
+
set_default :port, '22'
|
5
|
+
set_default :ssh_options, '-t'
|
6
|
+
set_default :forward_agent, true
|
7
|
+
set_default :term_mode, :nil
|
8
|
+
set_default :rails_env, 'staging'
|
9
|
+
set_default :shared_paths, ['tmp', 'log', 'public/uploads', 'config/database.yml']
|
10
|
+
set_default :branch, 'staging'
|
11
|
+
set_default :deploy_to, "/home/#{user}/#{application}/#{deploy_server}"
|
12
|
+
|
13
|
+
set_default :sockets_path, "#{deploy_to}/#{shared_path}/tmp/sockets"
|
14
|
+
set_default :pids_path, "#{deploy_to}/#{shared_path}/tmp/pids"
|
15
|
+
set_default :logs_path, "#{deploy_to}/#{shared_path}/log"
|
16
|
+
set_default :templates_path, "lib/mina/templates"
|
17
|
+
set_default :config_path, "#{deploy_to}/#{shared_path}/config"
|
18
|
+
|
19
|
+
set_default :unicorn_socket, "#{sockets_path}/unicorn.sock"
|
20
|
+
set_default :unicorn_pid, "#{pids_path}/unicorn.pid"
|
21
|
+
set_default :unicorn_config, "#{config_path}/unicorn.rb"
|
22
|
+
set_default :unicorn_workers, 1
|
23
|
+
set_default :unicorn_log, "#{logs_path}/unicorn.log"
|
24
|
+
set_default :unicorn_user, user
|
25
|
+
set_default :unicorn_script, "/etc/init.d/unicorn_#{application}_#{deploy_server}"
|
26
|
+
|
27
|
+
set_default :nginx_config, "#{nginx_path}/sites-enabled/#{application}_#{deploy_server}"
|
28
|
+
set_default :nginx_log_path, "#{deploy_to}/#{shared_path}/log/nginx"
|
29
|
+
set_default :nginx_server_name, domain || server_ip
|
30
|
+
|
31
|
+
set_default :postgresql_host, "localhost"
|
32
|
+
set_default :postgresql_user, application
|
33
|
+
set_default :postgresql_database, "#{application}_#{deploy_server}"
|
34
|
+
set_default :postgresql_pid, "/var/run/postgresql/9.1-main.pid"
|
35
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<% if config[:config_settings][:mina][:irc] %>
|
2
|
+
require 'carrier-pigeon'
|
3
|
+
|
4
|
+
namespace :irc do
|
5
|
+
desc "Announce deploy to irc"
|
6
|
+
task :announce_deploy do
|
7
|
+
send_irc_message "#{ENV['USER'].capitalize} is deploying #{application_name || application} to #{server}"
|
8
|
+
end
|
9
|
+
|
10
|
+
task :announce_seed do
|
11
|
+
send_irc_message "#{ENV['USER'].capitalize} is seeding the database for #{application_name || application} #{server}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def send_irc_message(message)
|
16
|
+
CarrierPigeon.send(
|
17
|
+
:uri => "irc://<%= config[:config_settings][:mina][:irc][:nick] %><%= ":#{config[:config_settings][:irc][:password] if config[:config_settings][:irc][:password]}" %>@<%= config[:config_settings][:irc][:domain] %>:<%= config[:config_settings][:irc][:port] %>/<%= config[:config_settings][:irc][:channel] %>",
|
18
|
+
:message => message,
|
19
|
+
:ssl => <%= config[:config_settings][:irc][:ssl] %>
|
20
|
+
)
|
21
|
+
end
|
22
|
+
<% end -%>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
namespace :log do
|
2
|
+
desc "View tail of rails log"
|
3
|
+
task :rails do
|
4
|
+
queue "tail #{logs_path}/#{rails_env}.log -n <%= config[:config_settings][:mina][:log][:tail_length] %>"
|
5
|
+
end
|
6
|
+
|
7
|
+
desc "View tail of unicorn log"
|
8
|
+
task :unicorn do
|
9
|
+
queue "tail #{unicorn_log} -n <%= config[:config_settings][:mina][:log][:tail_length] %>"
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "View tail of nginx error log"
|
13
|
+
task :nginx do
|
14
|
+
queue "tail /var/log/nginx/error.log -n <%= config[:config_settings][:mina][:log][:tail_length] %>"
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "View tail of nginx access log"
|
18
|
+
task :nginx_access do
|
19
|
+
queue "tail /var/log/nginx/access.log -n <%= config[:config_settings][:mina][:log][:tail_length] %>"
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
namespace :nginx do
|
2
|
+
desc "Setup nginx configuration for this application"
|
3
|
+
task :setup do
|
4
|
+
queue 'echo "-----> Creating nginx config"'
|
5
|
+
template "nginx_unicorn.erb", "/etc/nginx/sites-enabled/#{application}_#{deploy_server}", :tee, :sudo
|
6
|
+
queue 'echo "-----> Deleting nginx default site"' if verbose_mode?
|
7
|
+
queue echo_cmd "sudo rm -f /etc/nginx/sites-enabled/default"
|
8
|
+
invoke :'nginx:restart'
|
9
|
+
end
|
10
|
+
|
11
|
+
task :remove do
|
12
|
+
queue 'echo "-----> Deleting nginx config"'
|
13
|
+
queue "sudo rm -f /etc/nginx/sites-enabled/#{application}_#{deploy_server}"
|
14
|
+
invoke :'nginx:restart'
|
15
|
+
end
|
16
|
+
|
17
|
+
%w[start stop restart].each do |command|
|
18
|
+
desc "#{command} nginx"
|
19
|
+
task command do
|
20
|
+
queue echo_cmd "sudo service nginx #{command}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'highline/import'
|
2
|
+
|
3
|
+
namespace :postgresql do
|
4
|
+
desc "Generate the database.yml configuration file"
|
5
|
+
task :setup do
|
6
|
+
get_postgresql_password
|
7
|
+
invoke :'postgresql:create_user'
|
8
|
+
invoke :'postgresql:create_database'
|
9
|
+
template "postgresql.yml.erb", "#{config_path}/database.yml"
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Create a user for this application."
|
13
|
+
task :create_user do
|
14
|
+
get_postgresql_password
|
15
|
+
queue %{sudo -u postgres psql -c "create user \\"#{postgresql_user}\\" with password '#{postgresql_password}';"; true}
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Create a database for this application."
|
19
|
+
task :create_database do
|
20
|
+
queue %Q{sudo -u postgres psql -c "create database \\"#{postgresql_database}\\" owner \\"#{postgresql_user}\\";"; true}
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Symlink the database.yml file into latest release"
|
24
|
+
task :symlink do
|
25
|
+
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
|
26
|
+
end
|
27
|
+
after "deploy:finalize_update", "postgresql:symlink"
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_postgresql_password
|
31
|
+
if !postgresql_password
|
32
|
+
pw = ask "Postgresql password: " do |p|
|
33
|
+
p.echo = '*'
|
34
|
+
end
|
35
|
+
set :postgresql_password, pw
|
36
|
+
end
|
37
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
upstream unicorn_<%= "#{application}_#{
|
2
|
-
server unix:/tmp/unicorn.<%= "#{application}_#{
|
1
|
+
upstream unicorn_<%= "#{application}_#{deploy_server}" %> {
|
2
|
+
server unix:/tmp/unicorn.<%= "#{application}_#{deploy_server}" %>.sock fail_timeout=0;
|
3
3
|
}
|
4
4
|
|
5
5
|
<% if rewrite_www %>
|
@@ -16,9 +16,9 @@ server {
|
|
16
16
|
# Server configuration #
|
17
17
|
############################
|
18
18
|
server {
|
19
|
-
listen 80<%= " default_server" if
|
20
|
-
server_name <%= domain_name %>;
|
21
|
-
root /home/<%= user %>/<%= application %>/<%=
|
19
|
+
listen 80<%= " default_server" if default_host %>;
|
20
|
+
server_name <%= domain_name %><%= " #{server_ip}" if default_host %>;
|
21
|
+
root /home/<%= user %>/<%= application %>/<%= deploy_server %>/current/public;
|
22
22
|
|
23
23
|
location ^~ /assets/ {
|
24
24
|
gzip_static on;
|
@@ -31,7 +31,7 @@ server {
|
|
31
31
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
32
32
|
proxy_set_header Host $http_host;
|
33
33
|
proxy_redirect off;
|
34
|
-
proxy_pass http://unicorn_<%= application %>_<%=
|
34
|
+
proxy_pass http://unicorn_<%= application %>_<%= deploy_server %>;
|
35
35
|
}
|
36
36
|
|
37
37
|
error_page 500 502 503 504 /500.html;
|
@@ -46,7 +46,7 @@ server {
|
|
46
46
|
ssl on;
|
47
47
|
ssl_certificate /path/to/certificate/certificate.combined.crt;
|
48
48
|
ssl_certificate_key /path/to/key/server.key;
|
49
|
-
root /home/<%= user %>/apps/<%= application %>/<%=
|
49
|
+
root /home/<%= user %>/apps/<%= application %>/<%= deploy_server %>/current/public;
|
50
50
|
|
51
51
|
location ^~ /assets/ {
|
52
52
|
gzip_static on;
|
@@ -59,7 +59,7 @@ server {
|
|
59
59
|
proxy_set_header X-Forwarded-Proto $scheme;
|
60
60
|
proxy_set_header Host $http_host;
|
61
61
|
proxy_redirect off;
|
62
|
-
proxy_pass http://unicorn_<%= application %>_<%=
|
62
|
+
proxy_pass http://unicorn_<%= application %>_<%= deploy_server %>;
|
63
63
|
}
|
64
64
|
|
65
65
|
error_page 500 502 503 504 /500.html;
|
File without changes
|
@@ -1,10 +1,10 @@
|
|
1
|
-
working_directory "<%= current_path %>"
|
1
|
+
working_directory "<%= deploy_to %>/<%= current_path %>"
|
2
2
|
pid "<%= unicorn_pid %>"
|
3
3
|
stderr_path "<%= unicorn_log %>"
|
4
4
|
stdout_path "<%= unicorn_log %>"
|
5
5
|
preload_app true
|
6
6
|
|
7
|
-
listen "/tmp/unicorn.<%= "#{application}_#{
|
7
|
+
listen "/tmp/unicorn.<%= "#{application}_#{deploy_server}" %>.sock"
|
8
8
|
worker_processes <%= unicorn_workers %>
|
9
9
|
timeout 30
|
10
10
|
|
@@ -12,9 +12,9 @@ set -e
|
|
12
12
|
|
13
13
|
# Feel free to change any of the following variables for your app:
|
14
14
|
TIMEOUT=${TIMEOUT-60}
|
15
|
-
APP_ROOT=<%=
|
15
|
+
APP_ROOT=<%= deploy_to %>/current
|
16
16
|
PID=<%= unicorn_pid %>
|
17
|
-
CMD="cd
|
17
|
+
CMD="cd $APP_ROOT; bundle exec unicorn -D -c <%= unicorn_config %> -E <%= rails_env %>"
|
18
18
|
AS_USER=<%= unicorn_user %>
|
19
19
|
set -u
|
20
20
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
namespace :unicorn do
|
2
|
+
desc "Setup Unicorn initializer and app configuration"
|
3
|
+
task :setup do
|
4
|
+
queue 'echo "-----> Creating unicorn configuration file"'
|
5
|
+
queue "mkdir -p #{shared_path}/config"
|
6
|
+
template "unicorn.rb.erb", unicorn_config
|
7
|
+
|
8
|
+
queue 'echo "-----> Creating unicorn init script"'
|
9
|
+
template "unicorn_init.erb", unicorn_script, :tee, :sudo
|
10
|
+
queue echo_cmd "sudo chmod +x #{unicorn_script}"
|
11
|
+
queue echo_cmd "sudo update-rc.d -f unicorn_#{application}_#{deploy_server} defaults"
|
12
|
+
end
|
13
|
+
|
14
|
+
%w[start stop restart].each do |command|
|
15
|
+
desc "#{command.capitalize} unicorn"
|
16
|
+
task command do
|
17
|
+
queue %{echo "-----> #{command.capitalize} Unicorn"}
|
18
|
+
queue echo_cmd "/etc/init.d/unicorn_#{application}_#{deploy_server} #{command}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
task :setup do
|
2
|
+
invoke :create_extra_paths
|
3
|
+
invoke :'postgresql:setup'
|
4
|
+
invoke :'nginx:setup'
|
5
|
+
invoke :'unicorn:setup'
|
6
|
+
invoke :'logrotate:setup'
|
7
|
+
end
|
8
|
+
|
9
|
+
task :echo_config do
|
10
|
+
queue %{echo #{rails_env}}
|
11
|
+
queue %{echo #{deploy_to}}
|
12
|
+
queue %{echo #{shared_path}}
|
13
|
+
queue %{echo #{shared_paths.first}}
|
14
|
+
end
|
15
|
+
|
16
|
+
task :create_extra_paths do
|
17
|
+
queue 'echo "-----> Create configs path"'
|
18
|
+
queue echo_cmd "mkdir -p #{config_path}"
|
19
|
+
|
20
|
+
queue 'echo "-----> Create shared paths"'
|
21
|
+
shared_dirs = shared_paths.map { |file| "#{deploy_to}/#{shared_path}/#{file}" }.uniq
|
22
|
+
cmds = shared_dirs.map do |dir|
|
23
|
+
queue echo_cmd %{mkdir -p "#{dir}"}
|
24
|
+
end
|
25
|
+
|
26
|
+
queue 'echo "-----> Create PID and Sockets paths"'
|
27
|
+
cmds = [pids_path, sockets_path].map do |path|
|
28
|
+
queue echo_cmd %{mkdir -p #{path}}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def template(from, to, *opts)
|
33
|
+
queue %{echo "-----> Creating file at #{to} using template #{from}"}
|
34
|
+
if opts.include? :tee
|
35
|
+
command = ''
|
36
|
+
command << 'sudo ' if opts.include? :sudo
|
37
|
+
command << %{tee #{to} <<'zzENDOFFILEzz' > /dev/null\n}
|
38
|
+
command << %{#{erb("#{templates_path}/#{from}")}}
|
39
|
+
command << %{\nzzENDOFFILEzz}
|
40
|
+
else
|
41
|
+
command = %{echo '#{erb("#{templates_path}/#{from}")}' > #{to}}
|
42
|
+
end
|
43
|
+
queue echo_cmd command
|
44
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<h1>Editing <%=
|
1
|
+
<h1>Editing <%= human_name %></h1>
|
2
2
|
|
3
3
|
<%%= render 'form' %>
|
4
4
|
|
5
|
-
<%%= link_to
|
6
|
-
<%%= link_to
|
5
|
+
<%%= link_to icon(:info, text: 'Show'), @<%= singular_table_name %>, class: 'btn btn-primary' %> |
|
6
|
+
<%%= link_to icon(:arrow_left, text: 'Back to <%= plural_table_name.titleize %>'), <%= index_helper %>_path, class: 'btn btn-default' %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<h1><%= plural_table_name %></h1>
|
1
|
+
<h1><%= plural_table_name.titleize %></h1>
|
2
2
|
|
3
3
|
<table class="table">
|
4
4
|
<thead>
|
@@ -16,7 +16,11 @@
|
|
16
16
|
<td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
|
17
17
|
<% end -%>
|
18
18
|
<td>
|
19
|
-
<td
|
19
|
+
<td>
|
20
|
+
<%%= link_to icon(:info), <%= singular_table_name %>, class: 'btn btn-primary' %>
|
21
|
+
<%%= link_to icon(:edit), edit_<%= singular_table_name %>_path(<%= singular_table_name %>), class: 'btn btn-warning' %>
|
22
|
+
<%%= link_to icon(:trash_o), <%= singular_table_name %>, method: :delete, data: { confirm: "Are you sure you want to delete the #{human_name} '#{<%= singular_table_name %>}'?" }, class: 'btn btn-danger' %>
|
23
|
+
</td>
|
20
24
|
</td>
|
21
25
|
<%% end %>
|
22
26
|
</tbody>
|
@@ -24,4 +28,4 @@
|
|
24
28
|
|
25
29
|
<br />
|
26
30
|
|
27
|
-
<%%= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path, class: 'btn btn-
|
31
|
+
<%%= link_to icon(:plus, text: 'New <%= human_name %>'), new_<%= singular_table_name %>_path, class: 'btn btn-success' %>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<h1>New <%=
|
1
|
+
<h1>New <%= human_name %></h1>
|
2
2
|
|
3
3
|
<%%= render 'form' %>
|
4
4
|
|
5
|
-
<%%= link_to 'Back to <%= plural_table_name %>', <%= index_helper %>_path, class: 'btn btn-default' %>
|
5
|
+
<%%= link_to icon(:arrow_left, text: 'Back to <%= plural_table_name.titleize %>'), <%= index_helper %>_path, class: 'btn btn-default' %>
|
@@ -6,5 +6,5 @@
|
|
6
6
|
|
7
7
|
<% end -%>
|
8
8
|
|
9
|
-
<%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: 'btn btn-default' %>
|
10
|
-
<%%= link_to 'Back to <%= plural_table_name %>', <%= index_helper %>_path, class: 'btn btn-default' %>
|
9
|
+
<%%= link_to icon(:edit, text: 'Edit'), edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: 'btn btn-default' %>
|
10
|
+
<%%= link_to icon(:arrow_left, text: 'Back to <%= plural_table_name.titleize %>'), <%= index_helper %>_path, class: 'btn btn-default' %>
|
data/lib/trireme/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trireme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Sharpe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -57,7 +57,6 @@ files:
|
|
57
57
|
- lib/trireme/app_builder.rb
|
58
58
|
- lib/trireme/generators/app_generator.rb
|
59
59
|
- lib/trireme/templates/.rspec
|
60
|
-
- lib/trireme/templates/Capfile
|
61
60
|
- lib/trireme/templates/Guardfile
|
62
61
|
- lib/trireme/templates/README.md.erb
|
63
62
|
- lib/trireme/templates/additional_gems
|
@@ -69,28 +68,30 @@ files:
|
|
69
68
|
- lib/trireme/templates/app/views/shared/_flashes.html.erb
|
70
69
|
- lib/trireme/templates/app/views/shared/_form_errors.html.erb
|
71
70
|
- lib/trireme/templates/config/deploy.rb.erb
|
72
|
-
- lib/trireme/templates/config/deploy/production.rb
|
73
|
-
- lib/trireme/templates/config/deploy/staging.rb
|
71
|
+
- lib/trireme/templates/config/deploy/production.rb.erb
|
72
|
+
- lib/trireme/templates/config/deploy/staging.rb.erb
|
74
73
|
- lib/trireme/templates/config/environments/development.rb
|
75
74
|
- lib/trireme/templates/config/environments/production.rb
|
76
75
|
- lib/trireme/templates/config/environments/staging.rb
|
77
76
|
- lib/trireme/templates/config/environments/test.rb
|
78
77
|
- lib/trireme/templates/config/initializers/better_errors.rb
|
79
78
|
- lib/trireme/templates/config/initializers/jazz_hands.rb
|
80
|
-
- lib/trireme/templates/config/recipes/base.rb
|
81
|
-
- lib/trireme/templates/config/recipes/check.rb
|
82
|
-
- lib/trireme/templates/config/recipes/log.rb
|
83
|
-
- lib/trireme/templates/config/recipes/logrotate.rb
|
84
|
-
- lib/trireme/templates/config/recipes/nginx.rb
|
85
|
-
- lib/trireme/templates/config/recipes/postgresql.rb
|
86
|
-
- lib/trireme/templates/config/recipes/scripts/sql_functions.sql
|
87
|
-
- lib/trireme/templates/config/recipes/templates/logrotate.erb
|
88
|
-
- lib/trireme/templates/config/recipes/templates/nginx_unicorn.erb
|
89
|
-
- lib/trireme/templates/config/recipes/templates/postgresql.yml.erb
|
90
|
-
- lib/trireme/templates/config/recipes/templates/unicorn.rb.erb
|
91
|
-
- lib/trireme/templates/config/recipes/templates/unicorn_init.erb
|
92
|
-
- lib/trireme/templates/config/recipes/unicorn.rb
|
93
79
|
- lib/trireme/templates/gitignore_additions
|
80
|
+
- lib/trireme/templates/lib/mina/check.rb
|
81
|
+
- lib/trireme/templates/lib/mina/db.rb.erb
|
82
|
+
- lib/trireme/templates/lib/mina/defaults.rb
|
83
|
+
- lib/trireme/templates/lib/mina/irc.rb.erb
|
84
|
+
- lib/trireme/templates/lib/mina/log.rb.erb
|
85
|
+
- lib/trireme/templates/lib/mina/logrotate.rb
|
86
|
+
- lib/trireme/templates/lib/mina/nginx.rb
|
87
|
+
- lib/trireme/templates/lib/mina/postgresql.rb
|
88
|
+
- lib/trireme/templates/lib/mina/templates/logrotate.erb
|
89
|
+
- lib/trireme/templates/lib/mina/templates/nginx_unicorn.erb
|
90
|
+
- lib/trireme/templates/lib/mina/templates/postgresql.yml.erb
|
91
|
+
- lib/trireme/templates/lib/mina/templates/unicorn.rb.erb
|
92
|
+
- lib/trireme/templates/lib/mina/templates/unicorn_init.erb
|
93
|
+
- lib/trireme/templates/lib/mina/unicorn.rb
|
94
|
+
- lib/trireme/templates/lib/mina/utility.rb
|
94
95
|
- lib/trireme/templates/lib/templates/erb/scaffold/_form.html.erb
|
95
96
|
- lib/trireme/templates/lib/templates/erb/scaffold/edit.html.erb
|
96
97
|
- lib/trireme/templates/lib/templates/erb/scaffold/index.html.erb
|
@@ -1,17 +0,0 @@
|
|
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"
|
@@ -1,8 +0,0 @@
|
|
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
|
@@ -1,17 +0,0 @@
|
|
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
|
@@ -1,32 +0,0 @@
|
|
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
|
@@ -1,23 +0,0 @@
|
|
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;
|
@@ -1,26 +0,0 @@
|
|
1
|
-
set_default(:unicorn_user) { user }
|
2
|
-
set_default(:unicorn_pid) { "#{current_path}/tmp/pids/unicorn.pid" }
|
3
|
-
set_default(:unicorn_config) { "#{shared_path}/config/unicorn.rb" }
|
4
|
-
set_default(:unicorn_log) { "#{shared_path}/log/unicorn.log" }
|
5
|
-
set_default(:unicorn_workers, 2)
|
6
|
-
|
7
|
-
namespace :unicorn do
|
8
|
-
desc "Setup Unicorn initializer and app configuration"
|
9
|
-
task :setup, roles: :app do
|
10
|
-
run "mkdir -p #{shared_path}/config"
|
11
|
-
template "unicorn.rb.erb", unicorn_config
|
12
|
-
template "unicorn_init.erb", "/tmp/unicorn_init"
|
13
|
-
run "chmod +x /tmp/unicorn_init"
|
14
|
-
run "#{sudo} mv /tmp/unicorn_init /etc/init.d/unicorn_#{application}_#{rails_env}"
|
15
|
-
run "#{sudo} update-rc.d -f unicorn_#{application}_#{rails_env} defaults"
|
16
|
-
end
|
17
|
-
after "deploy:setup", "unicorn:setup"
|
18
|
-
|
19
|
-
%w[start stop restart].each do |command|
|
20
|
-
desc "#{command.capitalize} unicorn"
|
21
|
-
task command, roles: :app do
|
22
|
-
run "/etc/init.d/unicorn_#{application}_#{stage} #{command}"
|
23
|
-
end
|
24
|
-
after "deploy:#{command}", "unicorn:#{command}"
|
25
|
-
end
|
26
|
-
end
|