Skip to content

Commit 7734f0e

Browse files
committed
Continued setup of Capistrano
1 parent 91f5a69 commit 7734f0e

File tree

10 files changed

+64
-50
lines changed

10 files changed

+64
-50
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@
1515
/log/*.log
1616
/tmp
1717

18+
public/assets
19+
1820
.idea/

Capfile

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ require 'capistrano/deploy'
2323
# require 'capistrano/rails/migrations'
2424
# require 'capistrano/passenger'
2525

26-
require 'capistrano/bundler'
26+
# require 'capistrano/bundler'
2727
require 'capistrano/rails/migrations'
2828
require 'capistrano/rails/assets'
29-
require 'capistrano/rbenv'
30-
require 'capistrano/rbenv_install'
29+
# require 'capistrano/rvm'
30+
require 'rvm1/capistrano3'
31+
# require 'bundler/capistrano'
3132

3233
# Load custom tasks from `lib/capistrano/tasks' if you have any defined
3334
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

Gemfile

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
source 'https://rubygems.org'
22

3+
ruby '2.1.2'
34

45
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
56
gem 'rails', '4.1.1'
@@ -12,7 +13,7 @@ gem 'uglifier', '>= 1.3.0'
1213
# Use CoffeeScript for .js.coffee assets and views
1314
gem 'coffee-rails', '~> 4.0.0'
1415
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
15-
# gem 'therubyracer', platforms: :ruby
16+
gem 'therubyracer', platforms: :ruby
1617

1718
# Use jquery as the JavaScript library
1819
gem 'jquery-rails'
@@ -35,8 +36,8 @@ gem 'spring', group: :development
3536
# Use Capistrano for deployment
3637
gem 'capistrano-rails', group: :development
3738
gem 'capistrano-bundler', '~> 1.1.2'
38-
gem 'capistrano-rbenv', '~> 2.0'
39-
gem 'capistrano-rbenv-install', '~> 1.2.0'
39+
# gem 'capistrano-rvm'
40+
gem 'rvm1-capistrano3', require: false
4041

4142
# Use debugger
4243
# gem 'debugger', group: [:development, :test]
@@ -49,4 +50,5 @@ gem 'net-ping'
4950
gem 'ruby-nmap'
5051

5152
gem 'rack-mini-profiler'
52-
gem 'flamegraph'
53+
gem 'flamegraph'
54+
gem 'stackprof'

Gemfile.lock

+12-8
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ GEM
4040
capistrano-rails (1.1.2)
4141
capistrano (~> 3.1)
4242
capistrano-bundler (~> 1.1)
43-
capistrano-rbenv (2.0.3)
44-
capistrano (~> 3.1)
45-
sshkit (~> 1.3)
46-
capistrano-rbenv-install (1.2.0)
47-
capistrano (>= 3.0)
48-
capistrano-rbenv (>= 2.0)
4943
capistrano-stats (1.1.1)
5044
chronic (0.10.2)
5145
coffee-rails (4.0.1)
@@ -72,6 +66,7 @@ GEM
7266
railties (>= 3.0, < 5.0)
7367
thor (>= 0.14, < 2.0)
7468
json (1.8.2)
69+
libv8 (3.16.14.7)
7570
mail (2.5.4)
7671
mime-types (~> 1.16)
7772
treetop (~> 1.4.8)
@@ -112,10 +107,14 @@ GEM
112107
rb-readline (0.5.2)
113108
rdoc (4.2.0)
114109
json (~> 1.4)
110+
ref (1.0.5)
115111
rprogram (0.3.2)
116112
ruby-nmap (0.7.0)
117113
nokogiri (~> 1.3)
118114
rprogram (~> 0.3)
115+
rvm1-capistrano3 (1.3.2.2)
116+
capistrano (~> 3.0)
117+
sshkit (>= 1.2)
119118
sass (3.2.19)
120119
sass-rails (4.0.5)
121120
railties (>= 4.0.0, < 5.0)
@@ -140,6 +139,10 @@ GEM
140139
colorize (>= 0.7.0)
141140
net-scp (>= 1.1.2)
142141
net-ssh (>= 2.8.0)
142+
stackprof (0.2.7)
143+
therubyracer (0.12.1)
144+
libv8 (~> 3.16.14.0)
145+
ref
143146
thor (0.19.1)
144147
thread_safe (0.3.4)
145148
tilt (1.4.1)
@@ -162,8 +165,6 @@ PLATFORMS
162165
DEPENDENCIES
163166
capistrano-bundler (~> 1.1.2)
164167
capistrano-rails
165-
capistrano-rbenv (~> 2.0)
166-
capistrano-rbenv-install (~> 1.2.0)
167168
coffee-rails (~> 4.0.0)
168169
flamegraph
169170
jbuilder (~> 2.0)
@@ -173,10 +174,13 @@ DEPENDENCIES
173174
rails (= 4.1.1)
174175
rb-readline
175176
ruby-nmap
177+
rvm1-capistrano3
176178
sass-rails (~> 4.0.3)
177179
sdoc (~> 0.4.0)
178180
spring
179181
sqlite3
182+
stackprof
183+
therubyracer
180184
turbolinks
181185
uglifier (>= 1.3.0)
182186
whenever

app/controllers/index_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class IndexController < ApplicationController
77
def index
88
@sys_info = SysInfo.last
99
@status = Ping.current_status
10-
@uptime = @sys_info.uptime
10+
@uptime = @sys_info.try(:uptime, Time.now)
1111
@availability = Ping.availability
1212
@logs = Log.all
1313
@services = services

app/views/index/index.html.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
<div class="row">
44
<div class="col-xs-2">
5-
<div id="cpu-perc" data-cpu="<%= @sys_info.cpu %>"></div>
5+
<div id="cpu-perc" data-cpu="<%= @sys_info.try(:cpu, 'undefined') %>"></div>
66
</div>
77
<div id="cpu-graph" class="col-md-6 graph" data-cpu="<%= @cpu_history.to_json %>"></div>
88
</div>
99

1010
<div class="row">
1111
<div class="col-xs-2">
12-
<div id="ram-perc" data-ram="<%= @sys_info.ram %>"></div>
12+
<div id="ram-perc" data-ram="<%= @sys_info.try(:ram, 'undefined') %>"></div>
1313
</div>
1414
<div id="ram-graph" class="col-md-6 graph" data-ram="<%= @ram_history.to_json %>"></div>
1515
</div>

config/deploy.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
set :application, 'serben-status'
55
set :repo_url, 'https://github.com/edomora97/serben-status-new'
66

7-
set :rbenv_ruby, '2.1.3'
7+
set :rvm1_ruby_version, '2.1.3'
88

99
# Default branch is :master
1010
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call

config/deploy/production.rb

+13-30
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,25 @@
44
# is considered to be the first unless any hosts have the primary
55
# property set. Don't declare `role :all`, it's a meta role.
66

7-
role :app, %w{[email protected]}
8-
role :web, %w{[email protected]}
9-
role :db, %w{[email protected]}
10-
117

128
# Extended Server Syntax
139
# ======================
1410
# This can be used to drop a more detailed server definition into the
1511
# server list. The second argument is a, or duck-types, Hash and is
1612
# used to set extended properties on the server.
1713

18-
server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
14+
server 'vps.edo', user: 'deploy', roles: %w{web app db}
1915

16+
namespace :app do
17+
task :update_rvm_key do
18+
on roles(:all) do
19+
execute :gpg, '--keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3'
20+
end
21+
end
22+
end
23+
before 'rvm1:install:rvm', 'app:update_rvm_key'
2024

21-
# Custom SSH Options
22-
# ==================
23-
# You may pass any option but keep in mind that net/ssh understands a
24-
# limited set of options, consult[net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start).
25-
#
26-
# Global options
27-
# --------------
28-
# set :ssh_options, {
29-
# keys: %w(/home/rlisowski/.ssh/id_rsa),
30-
# forward_agent: false,
31-
# auth_methods: %w(password)
32-
# }
33-
#
34-
# And/or per server (overrides global)
35-
# ------------------------------------
36-
# server 'example.com',
37-
# user: 'user_name',
38-
# roles: %w{web app},
39-
# ssh_options: {
40-
# user: 'user_name', # overrides user setting above
41-
# keys: %w(/home/user_name/.ssh/id_rsa),
42-
# forward_agent: false,
43-
# auth_methods: %w(publickey password)
44-
# # password: 'please use keys'
45-
# }
25+
before 'deploy', 'rvm1:install:rvm'
26+
before 'deploy', 'rvm1:install:ruby'
27+
before 'deploy', 'rvm1:install:gems'
28+
# after 'rvm1:install:ruby', 'deploy:install_bundler'

config/deploy/staging.rb

+22
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,25 @@
1212
# used to set extended properties on the server.
1313

1414
server 'vps.edo', user: 'deploy', roles: %w{web app db}
15+
16+
namespace :app do
17+
task :update_rvm_key do
18+
on roles(:all) do
19+
execute :gpg, '--keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3'
20+
end
21+
end
22+
end
23+
before 'rvm1:install:rvm', 'app:update_rvm_key'
24+
25+
namespace :deploy do
26+
task :install_bundler do
27+
on roles(:all) do
28+
gem 'bundler'
29+
end
30+
end
31+
end
32+
33+
before 'deploy', 'rvm1:install:rvm'
34+
before 'deploy', 'rvm1:install:ruby'
35+
before 'deploy', 'rvm1:install:gems'
36+
# after 'rvm1:install:ruby', 'deploy:install_bundler'

test/controllers/index_controller_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'test_helper'
22

33
class IndexControllerTest < ActionController::TestCase
4-
test "should get index" do
4+
test 'should get index' do
55
get :index
66
assert_response :success
77
end

0 commit comments

Comments
 (0)