cap-runit 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3e6b7e1396dc85e4f664fac65423f7b17eb80e5
4
- data.tar.gz: e68549492f3f0e5cf8301dd473b15ea4fe778347
3
+ metadata.gz: 4d248458e4635f21b235037608eb6f0ded387d48
4
+ data.tar.gz: 50b7d8bac0241bbd03aee2f8c02bfed69f2e9a2e
5
5
  SHA512:
6
- metadata.gz: 0fd9c847ffb4cb4fffd273b5cd754b66f1a985427ca1e4c9fb303e7dff41ae4ff69a7d2577374836a0fa9bf2aa03cd50f0eca5bc771db15ace1f68d8d07e73af
7
- data.tar.gz: d84be89f74bb843f7f3a676962463e1b6c68c31f8879eac2c0d84fdd670f89d7f2bab9547dd936ecd187e169513895b703685ac2e03678600b710cec392c11d2
6
+ metadata.gz: a4c28fbf9a20dda07d1a88c3ab3e0db9a4ec5e8ae9e060988b48250286b7c582e39e7ca1c5f7d463458d161773ee5388efeb3e6ee49b9dbff32953b2bddf6a3d
7
+ data.tar.gz: f5fcec5a9bcac33e42cd8ab2943ea9a8be2c19fb89a3a7aab1992781040402e8be051fc0686caf7d5935c5c235ae4661e9d62d53d0e9de1fa8fda88a652c8d5c
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/README.md CHANGED
@@ -5,11 +5,16 @@ deploy services using capistrano 3 and run them with runit.
5
5
 
6
6
  ## Installation
7
7
 
8
- Using bundler: Add `gem 'cap-runit'` to your `Gemfile` and `require 'bundler';
9
- Bundler.require` to your `Capfile`.
8
+ #### Using bundler
10
9
 
11
- Not using bundler: `gem install cap-runit` and add `require 'capistrano/runit'`
12
- to your `Capfile`.
10
+ 1. Add `gem 'cap-runit'` to your `Gemfile`
11
+ 2. Run `bundle install`
12
+ 3. Add `require 'bundler'; Bundler.require` to your `Capfile`
13
+
14
+ #### Without bundler
15
+
16
+ 1. Run `gem install cap-runit`
17
+ 2. Add `require 'capistrano/runit' to your `Capfile`
13
18
 
14
19
  ## Usage
15
20
 
@@ -23,6 +28,9 @@ For example, to run sidekiq, you might do something like this:
23
28
  ```ruby
24
29
  runit_service 'sidekiq' do
25
30
 
31
+ # Sidekiq should only run on servers with role: %w{sidekiq}
32
+ roles :sidekiq
33
+
26
34
  run <<-EOF
27
35
  #!/bin/bash
28
36
  cd /var/www/app/current
@@ -59,6 +67,8 @@ automatically.
59
67
  ```ruby
60
68
  runit_service 'sidekiq' do
61
69
 
70
+ roles :sidekiq
71
+
62
72
  run <<-EOF
63
73
  #!/bin/bash -l
64
74
  cd /var/www/app/current
@@ -73,6 +83,9 @@ exec svlogd -tt /var/log/sidekiq
73
83
  end
74
84
  ```
75
85
 
86
+ N.B. For this example to work you will need to ensure that `/var/log/sidekiq`
87
+ can be written to by the capistrano user.
88
+
76
89
  ### Crash notifications
77
90
 
78
91
  If you need to be notified of when a crash happens in your app, you can also
@@ -81,6 +94,8 @@ configure a `finish` script. This is run whenever the `run` script exits.
81
94
  ```ruby
82
95
  runit_service 'sidekiq' do
83
96
 
97
+ roles :sidekiq
98
+
84
99
  run <<-EOF
85
100
  #!/bin/bash -l
86
101
  cd /var/www/app/current
@@ -110,8 +125,9 @@ The only configuration variable you need to pass is `runit_service_directory`
110
125
  set :runit_service_directory, "/apps/service"
111
126
  ```
112
127
 
113
- The service directory needs to be run with `runsvdir` and owned by the
114
- capistrano user. To configure `runsvdir` you can create the following files:
128
+ This should point to a directory that is being run by runit, and which the
129
+ capistrano user has permission to modify. I suggest setting up something like
130
+ `/apps/service` run by the `deploy` user. This can be done by creating two files:
115
131
 
116
132
 
117
133
  ```bash
@@ -127,10 +143,9 @@ And
127
143
  #/etc/service/cap-runit/log/run
128
144
 
129
145
  #!/bin/sh
146
+ mkdir -p /var/log/cap-runit
130
147
  exec svlogd -tt /var/log/cap-runit
131
148
  ```
132
149
 
133
150
  These files should both be owned by root and `chmod +x`. This way the deploy
134
151
  user does not need root permissions to reboot a service on deploy.
135
-
136
-
data/cap-runit.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'cap-runit'
3
- gem.version = '0.1'
3
+ gem.version = '0.2.0'
4
4
 
5
5
  gem.summary = 'Capistrano 3 Runit integration'
6
6
  gem.description = "Template for managing runit directories with capistrano 3"
data/lib/cap-runit.rb CHANGED
@@ -115,6 +115,14 @@ def runit_service(name, &block)
115
115
  execute "sv stop #{runit_service_dir}/#{name}"
116
116
  end
117
117
  end
118
+
119
+ desc "Force stop #{name}"
120
+ task :force_stop do
121
+ on roles(*service.roles) do
122
+ execute "sv force-stop #{runit_service_dir}/#{name}"
123
+ end
124
+ end
125
+ task :'force-stop' => :force_stop
118
126
 
119
127
  desc "Restart #{name}"
120
128
  task restart: :configure do
@@ -122,6 +130,14 @@ def runit_service(name, &block)
122
130
  execute "sv restart #{runit_service_dir}/#{name}"
123
131
  end
124
132
  end
133
+
134
+ desc "Force restart #{name}"
135
+ task force_restart: :configure do
136
+ on roles(*service.roles) do
137
+ execute "sv force-restart #{runit_service_dir}/#{name}"
138
+ end
139
+ end
140
+ task :'force-restart' => :force_restart
125
141
 
126
142
  desc "Disable #{name}"
127
143
  task :disable do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cap-runit
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conrad Irwin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-27 00:00:00.000000000 Z
11
+ date: 2014-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -31,6 +31,7 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - .gitignore
34
35
  - README.md
35
36
  - cap-runit.gemspec
36
37
  - lib/cap-runit.rb