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 +4 -4
- data/.gitignore +1 -0
- data/README.md +23 -8
- data/cap-runit.gemspec +1 -1
- data/lib/cap-runit.rb +16 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d248458e4635f21b235037608eb6f0ded387d48
|
4
|
+
data.tar.gz: 50b7d8bac0241bbd03aee2f8c02bfed69f2e9a2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
9
|
-
Bundler.require` to your `Capfile`.
|
8
|
+
#### Using bundler
|
10
9
|
|
11
|
-
|
12
|
-
|
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
|
-
|
114
|
-
capistrano user
|
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
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:
|
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-
|
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
|