myrails 4.0.0 → 5.0.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/myrails.rb +366 -167
- data/lib/myrails/templates/capistrano/config/deploy/templates/maintenance/index.html +41 -0
- data/lib/myrails/templates/capistrano/config/deploy/templates/monit.conf.erb +4 -0
- data/lib/myrails/templates/capistrano/config/deploy/templates/nginx.conf.erb +69 -0
- data/lib/myrails/templates/capistrano/config/deploy/templates/unicorn.rb.erb +26 -0
- data/lib/myrails/templates/capistrano/config/deploy/templates/unicorn_init.sh.erb +71 -0
- data/lib/myrails/templates/capistrano/lib/capistrano/tasks/maintenance.rake +16 -0
- data/lib/myrails/templates/capistrano/lib/capistrano/tasks/monit.rake +64 -0
- data/lib/myrails/templates/capistrano/lib/capistrano/tasks/nginx.rake +68 -0
- data/lib/myrails/templates/capistrano/lib/capistrano/tasks/unicorn.rake +114 -0
- data/lib/myrails/templates/{assets → rails/app/assets/javascripts}/application.js +0 -1
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets}/animate.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets}/application.css.sass +0 -2
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/cerulean.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/cosmo.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/cyborg.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/darkly.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/flatly.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/journal.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/lumen.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/paper.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/readable.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/sandstone.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/simplex.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/slate.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/spacelab.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/superhero.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/united.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets/bootstrap}/bootstrap_themes/yeti.scss +0 -0
- data/lib/myrails/templates/{assets → rails/app/assets/stylesheets}/will_paginate.scss +0 -0
- data/lib/myrails/templates/rails/{controller.rb → app/controllers/controller.rb} +0 -0
- data/lib/myrails/templates/rails/{namespace_controller.rb → app/controllers/namespace_controller.rb} +0 -0
- data/lib/myrails/templates/rails/{application_helper.rb → app/helpers/application_helper.rb} +0 -0
- data/lib/myrails/templates/{mailer → rails/app/mailers}/dev_mail_interceptor.rb +0 -0
- data/lib/myrails/templates/{mailer → rails/app/mailers}/sendgrid.rb +0 -0
- data/lib/myrails/templates/rails/{model.rb → app/models/model.rb} +0 -0
- data/lib/myrails/templates/rails/{namespace_model.rb → app/models/namespace_model.rb} +0 -0
- data/lib/myrails/templates/rails/{pundit.rb → app/policies/pundit.rb} +0 -0
- data/lib/myrails/templates/{presenters → rails/app/presenters}/base.rb +0 -0
- data/lib/myrails/templates/{presenters → rails/app/presenters}/presenter.rb +0 -0
- data/lib/myrails/templates/{presenters → rails/app/presenters}/presenter_config.rb +0 -0
- data/lib/myrails/templates/{presenters → rails/app/presenters}/presenter_spec.rb +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/_error_messages.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/_footer.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/_info_messages.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/_nav.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/_success_message.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/application.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/css/footer-distributed-with-address-and-phones.scss +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/css/footer-distributed-with-contact-form.scss +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/css/footer-distributed-with-search.scss +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/css/footer-distributed.scss +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/footer-distributed-with-address-and-phones.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/footer-distributed-with-contact-form.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/footer-distributed-with-search.html.haml +0 -0
- data/lib/myrails/templates/{layout → rails/app/views/layout/bootstrap}/footers/footer-distributed.html.haml +0 -0
- data/lib/myrails/templates/rails/app/views/layout/material/_detailed_pagination.html.haml +4 -0
- data/lib/myrails/templates/rails/app/views/layout/material/_error_messages.html.haml +9 -0
- data/lib/myrails/templates/rails/app/views/layout/material/_footer.html.haml +24 -0
- data/lib/myrails/templates/rails/app/views/layout/material/_info_messages.html.haml +14 -0
- data/lib/myrails/templates/rails/app/views/layout/material/_nav.html.haml +27 -0
- data/lib/myrails/templates/rails/app/views/layout/material/_simple_pagination.html.haml +2 -0
- data/lib/myrails/templates/rails/app/views/layout/material/_success_message.html.haml +7 -0
- data/lib/myrails/templates/rails/app/views/layout/material/application.html.haml +19 -0
- data/lib/myrails/templates/rails/app/views/layout/material/mailer.html.haml +246 -0
- data/lib/myrails/templates/rails/app/views/layout/material/mailer.text.haml +1 -0
- data/lib/myrails/templates/rails/config/application.example.yml +40 -0
- data/lib/myrails/templates/spec/controller.rb +123 -0
- data/lib/myrails/templates/{rspec → spec}/factory.rb +1 -1
- data/lib/myrails/templates/spec/feature.rb +8 -0
- data/lib/myrails/templates/{rspec → spec}/files.rb +0 -0
- data/lib/myrails/templates/spec/helper.rb +2 -0
- data/lib/myrails/templates/{rspec → spec}/model.rb +0 -0
- data/lib/myrails/templates/{rspec → spec}/pundit.rb +0 -0
- data/lib/myrails/templates/{rspec → spec}/request.rb +0 -0
- data/lib/myrails/templates/{rspec → spec}/request_shared_example.rb +0 -0
- data/lib/myrails/templates/{rspec → spec}/shared_example.rb +0 -0
- data/lib/myrails/templates/{rspec → spec/support/configs}/database_cleaner.rb +0 -0
- data/lib/myrails/templates/{rspec → spec/support/configs}/devise.rb +1 -1
- data/lib/myrails/templates/spec/support/configs/factory_bot.rb +3 -0
- data/lib/myrails/templates/{rspec → spec/support/configs}/mailer.rb +0 -0
- data/lib/myrails/templates/{rspec → spec/support/configs}/shoulda_matchers.rb +0 -0
- data/lib/myrails/templates/{rspec → spec/support/configs}/silence_backtrace.rb +0 -0
- data/lib/myrails/templates/spec/support/helpers/javascript.rb +12 -0
- data/lib/myrails/templates/spec/support/helpers/mailer.rb +9 -0
- data/lib/myrails/templates/spec/support/shared_examples/requires_authentication.rb +14 -0
- data/lib/myrails/templates/spec/support/shared_examples/requires_authorization.rb +16 -0
- data/lib/myrails/templates/spec/support/shared_examples/supports_file_type.rb +25 -0
- data/lib/myrails/version.rb +1 -1
- metadata +91 -68
- data/lib/myrails/templates/initializers/application_vars.rb +0 -2
- data/lib/myrails/templates/rails/application.yml +0 -19
- data/lib/myrails/templates/rspec/controller.rb +0 -98
- data/lib/myrails/templates/rspec/factory_girl.rb +0 -3
- data/lib/myrails/templates/rspec/javascript.rb +0 -8
- data/lib/myrails/templates/rspec/router.rb +0 -7
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<html lang="en">
|
|
2
|
+
<head>
|
|
3
|
+
<meta charset="utf-8">
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
5
|
+
<meta name="description" content="">
|
|
6
|
+
<meta name="author" content="">
|
|
7
|
+
<title>Lovell.Direct | Maintenance</title>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<style>
|
|
11
|
+
#upper_nav {background-color: #363940; padding: 20px; text-align: center;}
|
|
12
|
+
body {background-color: #ECECEC; margin: 0;}
|
|
13
|
+
.logo { background: url('/wtw_logo.png'); height: 49px; width: 74px; display: block; margin: 0 auto;}
|
|
14
|
+
#container_body {
|
|
15
|
+
text-align: center;
|
|
16
|
+
max-width: 600px;
|
|
17
|
+
padding: 0 20px;
|
|
18
|
+
margin: 0 auto;
|
|
19
|
+
color: #5a5a5a;
|
|
20
|
+
font-family: Helvetica-neue, Helvetica, sans-serif;
|
|
21
|
+
}
|
|
22
|
+
#container_body h4 { font-size: 24px; margin-bottom: 10px;}
|
|
23
|
+
#container_body p { font-size: 16px; margin-bottom: 20px;line-height: 24px;}
|
|
24
|
+
#container_body p a { color: #80c8ac; }
|
|
25
|
+
</style>
|
|
26
|
+
|
|
27
|
+
<body>
|
|
28
|
+
<div id="upper_nav">
|
|
29
|
+
<div class="logo"></div>
|
|
30
|
+
</div>
|
|
31
|
+
<div id='container_body'>
|
|
32
|
+
<h4>I'll be right back!</h4>
|
|
33
|
+
<p>I am currently applying some upgrades to make your experience even better.</p>
|
|
34
|
+
|
|
35
|
+
<p><i>lovell.direct should be back online shortly.</i></p>
|
|
36
|
+
|
|
37
|
+
<p>If you have any questions or concerns, you can send me a message at <a href="mailto:vmcilwain@me.com" target="_top">vmcilwain@me.com</a>.</p>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
</body>
|
|
41
|
+
</body>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
check process <%= fetch(:application) %>_unicorn with pidfile /var/www/<%= fetch(:application) %>/current/tmp/pids/unicorn.pid
|
|
2
|
+
start "/etc/init.d/<%= fetch(:application) %>_unicorn start"
|
|
3
|
+
stop "/etc/init.d/<%= fetch(:application) %>_unicorn stop"
|
|
4
|
+
group <%= fetch(:application) %>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
upstream <%= fetch(:application) %> {
|
|
2
|
+
# Path to Unicorn SOCK file, as defined previously
|
|
3
|
+
server unix:<%= current_path %>/tmp/sockets/unicorn.<%= fetch(:application) %>.sock fail_timeout=0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
server {
|
|
7
|
+
<%#- listen 80 default_server; %>
|
|
8
|
+
listen 443 ssl;
|
|
9
|
+
|
|
10
|
+
server_name <%= fetch(:fqdn) %> www.<%= fetch(:fqdn) %>;
|
|
11
|
+
ssl_certificate /etc/letsencrypt/live/<%= fetch(:fqdn) %>/fullchain.pem;
|
|
12
|
+
ssl_certificate_key /etc/letsencrypt/live/<%= fetch(:fqdn) %>/privkey.pem;
|
|
13
|
+
|
|
14
|
+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
|
15
|
+
ssl_prefer_server_ciphers on;
|
|
16
|
+
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
|
|
17
|
+
|
|
18
|
+
# Application root, as defined previously
|
|
19
|
+
root /var/www/<%= fetch(:application) %>/public;
|
|
20
|
+
|
|
21
|
+
try_files $uri/index.html $uri @<%= fetch(:application) %>;
|
|
22
|
+
|
|
23
|
+
location @<%= fetch(:application) %> {
|
|
24
|
+
proxy_pass http://<%= fetch(:application) %>;
|
|
25
|
+
proxy_set_header Host $http_host;
|
|
26
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
27
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
28
|
+
proxy_set_header X-Forwarded-Ssl on; # Optional
|
|
29
|
+
proxy_set_header X-Forwarded-Port $server_port;
|
|
30
|
+
proxy_set_header X-Forwarded-Host $host;
|
|
31
|
+
proxy_redirect off;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
error_page 500 502 503 504 /500.html;
|
|
35
|
+
client_max_body_size 4G;
|
|
36
|
+
keepalive_timeout 10;
|
|
37
|
+
|
|
38
|
+
if ( -f <%= shared_path %>/.maintenance ) {
|
|
39
|
+
set $maintenance 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if ( $uri ~ ^/maintenance/ ) {
|
|
43
|
+
set $maintenance 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if ( $maintenance ) {
|
|
47
|
+
rewrite (.*) /maintenance/index.html last;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
location ~ ^/(maintenance)/ {
|
|
51
|
+
root <%= shared_path %>/public;
|
|
52
|
+
gzip_static on; # to serve pre-gzipped version
|
|
53
|
+
expires max;
|
|
54
|
+
add_header Cache-Control public;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
location ~ ^/(assets)/ {
|
|
58
|
+
root <%= current_path %>/public;
|
|
59
|
+
gzip_static on; # to serve pre-gzipped version
|
|
60
|
+
expires max;
|
|
61
|
+
add_header Cache-Control public;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
server {
|
|
66
|
+
listen 80;
|
|
67
|
+
server_name <%= fetch(:fqdn) %> www.<%= fetch(:fqdn) %>;
|
|
68
|
+
return 301 https://$host$request_uri;
|
|
69
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# config/unicorn.rb
|
|
2
|
+
#
|
|
3
|
+
# Set the working application directory
|
|
4
|
+
# working_directory '/path/to/your/app'
|
|
5
|
+
working_directory "/var/www/<%= fetch(:application) %>/current"
|
|
6
|
+
|
|
7
|
+
# Unicorn PID file location
|
|
8
|
+
# pid '/path/to/pids/unicorn.pid'
|
|
9
|
+
pid "/var/www/<%= fetch(:application) %>/current/tmp/pids/unicorn.pid"
|
|
10
|
+
|
|
11
|
+
# Path to logs
|
|
12
|
+
# stderr_path '/path/to/log/unicorn.log'
|
|
13
|
+
# stdout_path '/path/to/log/unicorn.log'
|
|
14
|
+
stderr_path "/var/www/<%= fetch(:application) %>/current/log/unicorn.log"
|
|
15
|
+
stdout_path "/var/www/<%= fetch(:application) %>/current/log/unicorn.log"
|
|
16
|
+
|
|
17
|
+
# Unicorn socket
|
|
18
|
+
# listen '/tmp/unicorn.[application name].sock'
|
|
19
|
+
listen "<%= current_path %>/tmp/sockets/unicorn.<%= fetch(:application) %>.sock"
|
|
20
|
+
|
|
21
|
+
# Number of processes
|
|
22
|
+
# worker_processes 4
|
|
23
|
+
worker_processes 2
|
|
24
|
+
|
|
25
|
+
# Time-out
|
|
26
|
+
timeout 30
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -e
|
|
3
|
+
# Example init script, this can be used with nginx, too,
|
|
4
|
+
# since nginx and unicorn accept the same signals
|
|
5
|
+
|
|
6
|
+
# Feel free to change any of the following variables for your app:
|
|
7
|
+
TIMEOUT=${TIMEOUT-60}
|
|
8
|
+
APP_ROOT=/var/www/<%= fetch(:application) %>/current
|
|
9
|
+
PID=$APP_ROOT/tmp/pids/unicorn.pid
|
|
10
|
+
CMD="$APP_ROOT/bin/unicorn -D -c $APP_ROOT/config/unicorn.rb -E <%= fetch(:stage) %>"
|
|
11
|
+
action="$1"
|
|
12
|
+
set -u
|
|
13
|
+
|
|
14
|
+
old_pid="$PID.oldbin"
|
|
15
|
+
|
|
16
|
+
cd $APP_ROOT || exit 1
|
|
17
|
+
|
|
18
|
+
sig () {
|
|
19
|
+
test -s "$PID" && kill -$1 `cat $PID`
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
oldsig () {
|
|
23
|
+
test -s $old_pid && kill -$1 `cat $old_pid`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
case $action in
|
|
27
|
+
start)
|
|
28
|
+
sig 0 && echo >&2 "Already running" && exit 0
|
|
29
|
+
su -c "$CMD" - deploy
|
|
30
|
+
;;
|
|
31
|
+
stop)
|
|
32
|
+
sig QUIT && exit 0
|
|
33
|
+
echo >&2 "Not running"
|
|
34
|
+
;;
|
|
35
|
+
force-stop)
|
|
36
|
+
sig TERM && exit 0
|
|
37
|
+
echo >&2 "Not running"
|
|
38
|
+
;;
|
|
39
|
+
restart|reload)
|
|
40
|
+
sig HUP && echo reloaded OK && exit 0
|
|
41
|
+
echo >&2 "Couldn't reload, starting '$CMD' instead"
|
|
42
|
+
su -c "$CMD" - deploy
|
|
43
|
+
;;
|
|
44
|
+
upgrade)
|
|
45
|
+
if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
|
|
46
|
+
then
|
|
47
|
+
n=$TIMEOUT
|
|
48
|
+
while test -s $old_pid && test $n -ge 0
|
|
49
|
+
do
|
|
50
|
+
printf '.' && sleep 1 && n=$(( $n - 1 ))
|
|
51
|
+
done
|
|
52
|
+
echo
|
|
53
|
+
|
|
54
|
+
if test $n -lt 0 && test -s $old_pid
|
|
55
|
+
then
|
|
56
|
+
echo >&2 "$old_pid still exists after $TIMEOUT seconds"
|
|
57
|
+
exit 1
|
|
58
|
+
fi
|
|
59
|
+
exit 0
|
|
60
|
+
fi
|
|
61
|
+
echo >&2 "Couldn't upgrade, starting '$CMD' instead"
|
|
62
|
+
su -c "$CMD" - deploy
|
|
63
|
+
;;
|
|
64
|
+
reopen-logs)
|
|
65
|
+
sig USR1
|
|
66
|
+
;;
|
|
67
|
+
*)
|
|
68
|
+
echo >&2 "Usage: $0 "
|
|
69
|
+
exit 1
|
|
70
|
+
;;
|
|
71
|
+
esac
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
namespace :maintenance do
|
|
2
|
+
desc 'Turn maintenance mode ON'
|
|
3
|
+
task :on do
|
|
4
|
+
on roles(:app) do
|
|
5
|
+
execute :mkdir, "#{shared_path}/public/maintenance" if test("[ ! -d #{shared_path}/public/maintenance ]")
|
|
6
|
+
upload! "config/deploy/templates/maintenance/index.html", "#{shared_path}/public/maintenance/index.html"
|
|
7
|
+
execute :touch, "#{shared_path}/.maintenance"
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
desc 'Turn maintenance mode OFF'
|
|
11
|
+
task :off do
|
|
12
|
+
on roles(:app) do
|
|
13
|
+
execute :rm, "#{shared_path}/.maintenance"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Monit file for setting up monit during application deployment
|
|
2
|
+
set :template, "config/deploy/templates/monit.conf.erb"
|
|
3
|
+
set :monit_conf, "tmp/monit.conf"
|
|
4
|
+
|
|
5
|
+
namespace :monit do
|
|
6
|
+
|
|
7
|
+
desc 'creation of monit file for application'
|
|
8
|
+
task :write_monit_conf do
|
|
9
|
+
on roles(:app) do
|
|
10
|
+
info "Creating monit config"
|
|
11
|
+
open(fetch(:monit_conf), 'a') do |f|
|
|
12
|
+
f.puts(ERB.new(File.read("#{fetch(:template)}"), nil, '-').result(binding))
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc 'restart monit application'
|
|
18
|
+
task :reload do
|
|
19
|
+
on roles(:app) do
|
|
20
|
+
info 'Reloading initialize monit'
|
|
21
|
+
execute :sudo, 'service monit reload' # re-read /etc/monit/monitrc
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
desc 'stop monit application'
|
|
26
|
+
task :stop do
|
|
27
|
+
on roles(:app) do
|
|
28
|
+
info 'Stopping initialize monit'
|
|
29
|
+
execute :sudo, 'service monit stop'
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
desc 'start monit application'
|
|
34
|
+
task :start do
|
|
35
|
+
on roles(:app) do
|
|
36
|
+
info 'Starting initialize monit'
|
|
37
|
+
execute :sudo, 'service monit start'
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
desc 'upload monit config to app'
|
|
42
|
+
task :upload do
|
|
43
|
+
on roles(:app) do
|
|
44
|
+
upload!(fetch(:monit_conf), "#{current_path}/config")
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
desc 'remove temp file'
|
|
49
|
+
task :remove do
|
|
50
|
+
on roles(:app) do
|
|
51
|
+
FileUtils.rm(fetch(:monit_conf))
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
desc 'start creation of monit file for application'
|
|
56
|
+
task :create_monit_conf do
|
|
57
|
+
on roles(:app) do
|
|
58
|
+
info "Creating #{fetch(:application)} config/monit.config"
|
|
59
|
+
invoke 'monit:write_monit_conf'
|
|
60
|
+
invoke 'monit:upload'
|
|
61
|
+
invoke 'monit:remove'
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Capistrano file for setting up nginx during application deployment
|
|
2
|
+
set :nginx_template, 'config/deploy/templates/nginx.conf.erb'
|
|
3
|
+
set :nginx_conf, "tmp/nginx.conf"
|
|
4
|
+
|
|
5
|
+
namespace :nginx do
|
|
6
|
+
desc 'restart nginx'
|
|
7
|
+
task :restart do
|
|
8
|
+
on roles(:app) do
|
|
9
|
+
info 'Restarting nginx'
|
|
10
|
+
# execute :sudo, "fuser -k 80/tcp"
|
|
11
|
+
execute :sudo, 'service nginx stop'
|
|
12
|
+
execute :sudo, "service nginx start"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc "create #{fetch(:application)} nginx.conf"
|
|
17
|
+
task :generate_nginx_conf do
|
|
18
|
+
on roles(:app) do
|
|
19
|
+
info "Generating #{fetch(:application)} nginx.conf file"
|
|
20
|
+
open(fetch(:nginx_conf), 'w') do |f|
|
|
21
|
+
f.puts(ERB.new(File.read(fetch(:nginx_template))).result(binding))
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
desc "upload #{fetch(:application)} nginx.conf"
|
|
27
|
+
task :upload do
|
|
28
|
+
on roles(:app) do
|
|
29
|
+
upload!(fetch(:nginx_conf), "#{current_path}/config")
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
desc "delete local #{fetch(:application)} nginx.conf"
|
|
34
|
+
task :remove do
|
|
35
|
+
on roles(:app) do
|
|
36
|
+
info 'Removing local nginx.conf'
|
|
37
|
+
FileUtils.rm(fetch(:nginx_conf))
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
desc "create symlink for #{fetch(:application)} nginx.conf"
|
|
42
|
+
task :create_symlink do
|
|
43
|
+
on roles(:app) do
|
|
44
|
+
info 'Creating symlink on remote system'
|
|
45
|
+
execute :sudo, "ln -s #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{fetch(:application)}"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
desc "remove symlink for #{fetch(:application)} nginx.conf"
|
|
50
|
+
task :remove_symlink do
|
|
51
|
+
on roles(:app) do
|
|
52
|
+
info 'Removing symlink on remote system'
|
|
53
|
+
execute :sudo, "rm -rf /etc/nginx/sites-enabled/#{fetch(:application)}"
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
desc "add nginx config to #{fetch(:application)}"
|
|
58
|
+
task :create_nginx_config do
|
|
59
|
+
on roles(:app) do |host|
|
|
60
|
+
info "Creating #{fetch(:application)} nginx.conf"
|
|
61
|
+
invoke 'nginx:generate_nginx_conf'
|
|
62
|
+
invoke 'nginx:upload'
|
|
63
|
+
invoke 'nginx:remove'
|
|
64
|
+
invoke 'nginx:remove_symlink'
|
|
65
|
+
invoke 'nginx:create_symlink'
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Capistrano file for setting up unicorn during application deployment
|
|
2
|
+
set :template_path, 'config/deploy/templates'
|
|
3
|
+
set :unicorn_conf_template, "#{fetch(:template_path)}/unicorn.rb.erb"
|
|
4
|
+
set :unicorn_init_template, "#{fetch(:template_path)}/unicorn_init.sh.erb"
|
|
5
|
+
set :unicorn_conf, "tmp/unicorn.rb"
|
|
6
|
+
set :unicorn_init, "tmp/unicorn_init.sh"
|
|
7
|
+
|
|
8
|
+
namespace :unicorn do
|
|
9
|
+
desc "generate unicorn.conf for #{fetch(:application)}"
|
|
10
|
+
task :generate_unicorn_conf do
|
|
11
|
+
on roles(:app) do
|
|
12
|
+
info "generating #{fetch(:application)} unicorn.conf file"
|
|
13
|
+
open(fetch(:unicorn_conf), 'w') do |f|
|
|
14
|
+
f.puts(ERB.new(File.read(fetch(:unicorn_conf_template))).result(binding))
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc "generate unicorn_init.sh for #{fetch(:application)}"
|
|
20
|
+
task :generate_unicorn_init do
|
|
21
|
+
on roles(:app) do
|
|
22
|
+
info "generating #{fetch(:application)} unicorn_init.sh file"
|
|
23
|
+
open(fetch(:unicorn_init), 'w') do |f|
|
|
24
|
+
f.puts(ERB.new(File.read(fetch(:unicorn_init_template))).result(binding))
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
desc "upload #{fetch(:application)} unicorn.conf"
|
|
30
|
+
task :upload_unicorn_conf do
|
|
31
|
+
on roles(:app) do
|
|
32
|
+
upload!(fetch(:unicorn_conf), "#{current_path}/config")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
desc "upload #{fetch(:application)} unicorn_init.sh"
|
|
37
|
+
task :upload_unicorn_init do
|
|
38
|
+
on roles(:app) do
|
|
39
|
+
upload!(fetch(:unicorn_init), "#{current_path}/config")
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
desc "delete local #{fetch(:application)} unicorn.conf"
|
|
44
|
+
task :remove_unicorn_conf do
|
|
45
|
+
on roles(:app) do
|
|
46
|
+
info 'Deleting local unicorn.conf'
|
|
47
|
+
FileUtils.rm(fetch(:unicorn_conf))
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
desc "delete local #{fetch(:application)} unicorn.init.sh"
|
|
52
|
+
task :remove_unicorn_init do
|
|
53
|
+
on roles(:app) do
|
|
54
|
+
info 'Deleting local unicorn_init.sh'
|
|
55
|
+
FileUtils.rm(fetch(:unicorn_init))
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
desc "create symlink for #{fetch(:application)} unicorn_init.sh"
|
|
60
|
+
task :create_symlink do
|
|
61
|
+
on roles(:app) do
|
|
62
|
+
info 'Symlinking unicorn_init.sh'
|
|
63
|
+
execute :sudo, "chmod +x #{current_path}/config/unicorn_init.sh"
|
|
64
|
+
execute :sudo, "ln -s #{current_path}/config/unicorn_init.sh /etc/init.d/#{fetch(:application)}_unicorn"
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
desc "remove symlink for #{fetch(:application)} unicorn_init.sh"
|
|
69
|
+
task :remove_symlink do
|
|
70
|
+
on roles(:app) do
|
|
71
|
+
info 'Removing unicorn_init.sh symlink'
|
|
72
|
+
execute :sudo, "rm -rf /etc/init.d/unicorn-#{fetch(:application)}"
|
|
73
|
+
execute :sudo, "rm -rf /etc/init.d/#{fetch(:application)}_unicorn"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
desc "add unicorn config to #{fetch(:application)}"
|
|
78
|
+
task :create_unicorn_config do
|
|
79
|
+
on roles(:app) do |host|
|
|
80
|
+
invoke 'unicorn:generate_unicorn_conf'
|
|
81
|
+
invoke 'unicorn:upload_unicorn_conf'
|
|
82
|
+
invoke 'unicorn:remove_unicorn_conf'
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
desc "restart unicorn for #{fetch(:application)}"
|
|
87
|
+
task :restart do
|
|
88
|
+
on roles(:app) do
|
|
89
|
+
info 'Restarting unicorn'
|
|
90
|
+
execute :sudo, "/etc/init.d/#{fetch(:application)}_unicorn stop"
|
|
91
|
+
sleep 3
|
|
92
|
+
execute :sudo, "/etc/init.d/#{fetch(:application)}_unicorn start"
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
desc "Set auto-start of unicorn for #{fetch(:application)}"
|
|
97
|
+
task :autostart do
|
|
98
|
+
on roles(:app) do
|
|
99
|
+
info 'Setting unicorn autostart in rc.*'
|
|
100
|
+
execute :sudo, 'update-rc.d online_community_unicorn defaults'
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
desc "add unicorn init config to #{fetch(:application)}"
|
|
105
|
+
task :create_unicorn_init do
|
|
106
|
+
on roles(:app) do |host|
|
|
107
|
+
invoke 'unicorn:generate_unicorn_init'
|
|
108
|
+
invoke 'unicorn:upload_unicorn_init'
|
|
109
|
+
invoke 'unicorn:remove_unicorn_init'
|
|
110
|
+
invoke 'unicorn:remove_symlink'
|
|
111
|
+
invoke 'unicorn:create_symlink'
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|