capistrano-devops 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 796e319fadbfaf5d6b53b0b221bb027669c71a5c
4
- data.tar.gz: 1209a1ac9b6f6b7cc40c0eaa5191da3271d835b2
3
+ metadata.gz: bb762a5df31afd7dbbb7dfd068b99a22df9bc89e
4
+ data.tar.gz: 73aa1d0a9f46a26d81912acd1a5977a33b6ceee6
5
5
  SHA512:
6
- metadata.gz: 35c3f0ff34f8407f98df56bece0b2654aae5fcd308469ef152cc91ac49a0b41822ac1182481197fd14fdbaffb054a28cc7b36f24a3ce3f55d00dcc42e4d2ad86
7
- data.tar.gz: 496b4363a88a8c298f53377890512828fef20137c337eb603d01ff7337d540ebf8c5d448d0fd369b582205ddd1e4fd5262f281c12e829d724e8b2b159d065432
6
+ metadata.gz: d0a0f0bd27a41e04c080ee3ef0425127c5f366870d7ce9568742beacf34d754dd98269b88af24056afdff3aa4db4bffce6747102ded316f6e084e659f554742f
7
+ data.tar.gz: 75bcd6ef3704415f47ddbce0f9644fa0b48d1dcfac2274ac794dbf21f12c4f14f46483fa9ab30369894d422f7ac11f55c7bb9c3115e41787b5f391b8bbd94cf2
data/README.md CHANGED
@@ -18,7 +18,13 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- require 'capistrano/devops' in Capfile
21
+ add in Capfile
22
+
23
+ require 'capistrano/devops'
24
+
25
+ add in deploy.rb
26
+
27
+ set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
22
28
 
23
29
  ## Contributing
24
30
 
@@ -14,7 +14,7 @@ set -e
14
14
  TIMEOUT=${TIMEOUT-60}
15
15
  APP_ROOT=<%= current_path %>
16
16
  PID=<%= fetch(:rainbows_pid) %>
17
- CMD="cd <%= current_path %>; bundle exec rainbows -D -c <%= fetch(:rainbows_config) %> -E <%= fetch(:rails_env) %>"
17
+ CMD="cd <%= current_path %>; bundle exec rainbows -D -c <%= fetch(:rainbows_config) %> -E <%= fetch(:rails_env, 'production') %>"
18
18
  AS_USER=<%= fetch(:rainbows_user) %>
19
19
  set -u
20
20
 
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Devops
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -3,48 +3,76 @@ load File.expand_path("../set_rails_env.rake", __FILE__)
3
3
  namespace :papertrail do
4
4
  # desc 'Adds papertrail to rsyslog as an output channel'
5
5
  task :add_to_rsyslog do
6
- # as root add
7
- # *.* @logs.papertrailapp.com:31378
8
- # to the end of /etc/rsyslog.conf
9
-
10
- # restart rsyslog
11
- # sudo /etc/init.d/rsyslog restart
6
+ on roles(:all) do
7
+ as :root do
8
+ within '/etc' do
9
+ # TODO: this is awfully familiar to the ssh block, need to DRY up
10
+ file = capture(:cat, 'rsyslog.conf')
11
+ lines = file.split("\n")
12
+ lines << "*.* @#{fetch(:papertrail_host, 'logs.papertrailapp.com')}:#{fetch(:papertrail_port, 1234)}" + "\n"
13
+ new_file = StringIO.new(lines.join("\n"))
14
+ upload! new_file, '/tmp/rsyslog.conf'
15
+ execute :mv, '/tmp/rsyslog.conf', 'rsyslog.conf'
16
+ execute :service, 'rsyslog restart'
17
+ end
18
+ end
19
+ end
12
20
  end
13
21
 
14
- # desc 'Install remote_syslog'
22
+ # desc 'Install remote_syslog on all app servers'
15
23
  task :remote_syslog do
16
- # sudo gem install remote_syslog
17
- # Paths to log file(s) can be specified on the command-line, or save log_files.yml.example (typically as /etc/log_files.yml). Edit it to define:
18
- # - path to this app's log file, and any other log file(s) to watch.
19
- # - destination host and port (provided by Papertrail). You can find the settings by clicking Add System from the dashboard.
20
-
21
- # /etc/log_files.yml
22
- # files:
23
- # - /var/log/httpd/access_log
24
- # - /var/log/httpd/error_log
25
- # - /opt/misc/*.log
26
- # - /var/log/mysqld.log
27
- # - /var/run/mysqld/mysqld-slow.log
28
- # destination:
29
- # host: logs.papertrailapp.com
30
- # port: 12345 # NOTE: change to your Papertrail port
31
-
32
- # While remote_syslog does not need to run as root, it does need permission to write its PID file (by default to /var/run/remote_syslog.pid) and read permission on the log files it is monitoring.
33
-
34
- # remote_syslog.upstart.conf
35
- # description "Monitor files and send to remote syslog"
36
- # start on runlevel [2345]
37
- # stop on runlevel [!2345]
38
-
39
- # respawn
40
-
41
- # pre-start exec /usr/bin/test -e /etc/log_files.yml
42
-
43
- # exec /var/lib/gems/1.8/bin/remote_syslog -D --tls
24
+ on roles(:app) do
25
+ as :root do
26
+ execute :gem, 'install remote_syslog'
27
+
28
+ LOG_FILES_YML = <<-EOF
29
+ files:
30
+ - #{shared_path.join('log').to_s}/*
31
+ destination:
32
+ host: #{fetch(:papertrail_host, 'logs.papertrailapp.com')}
33
+ port: #{fetch(:papertrail_port, 1234)}
34
+ prepend: #{fetch(:application)}
35
+ EOF
36
+
37
+ within '/etc' do
38
+ # again, DRY this up (because as() doesn't work with upload! or within yet)
39
+ upload! StringIO.new(LOG_FILES_YML), '/tmp/log_files.yml'
40
+ execute :mv, '/tmp/log_files.yml', 'log_files.yml'
41
+ end
42
+
43
+ within '/etc/init' do
44
+
45
+ UPSTART_CONF = <<-EOF
46
+ description "Monitor files and send to remote syslog"
47
+ start on runlevel [2345]
48
+ stop on runlevel [!2345]
49
+
50
+ respawn
51
+
52
+ pre-start exec /usr/bin/test -e /etc/log_files.yml
53
+
54
+ exec /usr/local/bin/remote_syslog -D --tls
55
+ EOF
56
+
57
+ # TODO: find out where the remote_syslog is (or if it even got installed)
58
+ # find / -name remote_syslog
59
+
60
+ # again, DRY this up (because as() doesn't work with upload! or within yet)
61
+ upload! StringIO.new(UPSTART_CONF), '/tmp/remote_syslog.conf'
62
+ execute :mv, '/tmp/remote_syslog.conf', 'remote_syslog.conf'
63
+
64
+ end
65
+
66
+ execute :service, 'remote_syslog start'
67
+
68
+ end
69
+ end
44
70
  end
45
71
 
46
72
  desc 'Installs papertrail and adds remote_syslog'
47
73
  task :install do
74
+ invoke 'papertrail:add_to_rsyslog'
75
+ invoke 'papertrail:remote_syslog'
48
76
  end
49
77
 
50
78
  end
@@ -1,3 +1,5 @@
1
+ load File.expand_path("../set_rails_env.rake", __FILE__)
2
+
1
3
  namespace :ssh do
2
4
  desc 'Adds public key to the authorized_keys file (to enable passwordless login)'
3
5
  task :add_key do
data/sample_app/Gemfile CHANGED
@@ -37,6 +37,7 @@ end
37
37
 
38
38
  # Use unicorn as the app server
39
39
  gem 'rainbows'
40
+ gem 'eventmachine'
40
41
 
41
42
  group :development do
42
43
  # Use Capistrano for deployment
@@ -22,7 +22,7 @@ GIT
22
22
 
23
23
  GIT
24
24
  remote: git://github.com/parasquid/capistrano-devops.git
25
- revision: d84c855cda8545d39fa529ff454384c6734579a1
25
+ revision: cef01cf1a586a3584454ecdea62d4d45d4cf117e
26
26
  specs:
27
27
  capistrano-devops (0.0.1)
28
28
  capistrano (~> 3)
@@ -70,6 +70,7 @@ GEM
70
70
  execjs
71
71
  coffee-script-source (1.6.3)
72
72
  erubis (2.7.0)
73
+ eventmachine (1.0.3)
73
74
  execjs (2.0.2)
74
75
  hike (1.2.3)
75
76
  i18n (0.6.5)
@@ -172,6 +173,7 @@ DEPENDENCIES
172
173
  capistrano-rails
173
174
  capistrano-rbenv!
174
175
  coffee-rails (~> 4.0.0)
176
+ eventmachine
175
177
  jbuilder (~> 1.2)
176
178
  jquery-rails
177
179
  multi_json!
@@ -18,7 +18,7 @@ set :log_level, :debug
18
18
  # set :pty, true
19
19
 
20
20
  # set :linked_files, %w{config/database.yml}
21
- # set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
21
+ set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
22
22
 
23
23
  # set :default_env, { path: "/opt/ruby/bin:$PATH" }
24
24
  set :keep_releases, 5
@@ -55,6 +55,8 @@ namespace :deploy do
55
55
 
56
56
  end
57
57
 
58
- after "deploy:updating", "deploy:checkout_subdir"
58
+ before "deploy:symlink:shared", "deploy:checkout_subdir"
59
59
 
60
60
  end
61
+
62
+ set :papertrail_port, 31378
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-devops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - tristan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-07 00:00:00.000000000 Z
11
+ date: 2013-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano