mina-sidekiq 0.4.1 → 1.1.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 +5 -5
- data/.travis.yml +7 -6
- data/Changelog.md +21 -0
- data/Gemfile +3 -1
- data/README.md +117 -44
- data/Rakefile +1 -2
- data/lib/mina_sidekiq/tasks.rb +154 -53
- data/lib/mina_sidekiq/version.rb +1 -1
- data/mina-sidekiq.gemspec +3 -8
- data/test/deploy_test.rb +4 -2
- data/test/test_helper.rb +0 -1
- data/test_env/config/deploy.rb +11 -16
- metadata +35 -15
- data/Gemfile.lock +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b6b58dc398da8db743c4f5f063cf60cabc54e546463c8ca9504afed5855ee4a5
|
4
|
+
data.tar.gz: 46cd45d6d4ef1ab10a93892baf0fab90d7899b4520e2afd1a068e0fb90ab7dae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8902d7d2b9f28020b5049dcaf661fbf7ab07b644b9e4da7a5b737a628acbd38de5480386bd281430a9fbc7d3c7c28f7e4d63a48cd10030805b89af9bd18feee
|
7
|
+
data.tar.gz: dbff1c1aea66bb4a111e29fc3c9f5c368d22819b0e7e9329d558f99cefa9ce4bc199bc2bd8035ccd1b7b23b68f7a9fc7df5e1c9a3e2b5fd69b0f8aedf43a9f79
|
data/.travis.yml
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
2
|
+
cache: bundler
|
3
3
|
rvm:
|
4
|
-
- "
|
5
|
-
- "2.
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
- "2.2.5"
|
5
|
+
- "2.3.1"
|
6
|
+
|
7
|
+
before_install:
|
8
|
+
- ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa
|
9
|
+
- cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
|
data/Changelog.md
CHANGED
@@ -1,6 +1,27 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
1.1.0 2020-07-18
|
5
|
+
----------------
|
6
|
+
* Add sidekiq 6 support, including support for unprivileged deployments
|
7
|
+
* Allow multiple sidekiq process with different configs
|
8
|
+
|
9
|
+
1.0.3 2017-11-05
|
10
|
+
----------------
|
11
|
+
* replace deprecated dependency on environment task with remote_environment
|
12
|
+
|
13
|
+
1.0.2 2017-07-25
|
14
|
+
----------------
|
15
|
+
* fix undefined variable, which broke `sidekiq:log`
|
16
|
+
|
17
|
+
1.0.1 2016-11-17
|
18
|
+
----------------
|
19
|
+
* restore current directory after changing to sidekiq directory
|
20
|
+
|
21
|
+
1.0.0 2016-10-10
|
22
|
+
----------------
|
23
|
+
* support for mina 1.0 (thanks @devvmh)
|
24
|
+
|
4
25
|
0.4.1 2016-06-27
|
5
26
|
----------------
|
6
27
|
* Default `sidekiq_concurrency` to nil. It now needs explicitly set to
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,51 +1,114 @@
|
|
1
1
|
mina-sidekiq
|
2
2
|
============
|
3
3
|
|
4
|
-
|
4
|
+
mina-sidekiq is a gem that adds tasks to aid in the deployment of [Sidekiq](http://mperham.github.com/sidekiq/)
|
5
|
+
using [Mina](http://nadarei.co/mina).
|
5
6
|
|
6
|
-
|
7
|
-
using [Mina] (http://nadarei.co/mina).
|
7
|
+
Starting with 1.0.0 this gem requires Mina 1.0! (thanks [@devvmh](https://github.com/devvmh))
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
The original author of this library do not use mina nor sidekiq at the moment.
|
12
|
-
If you want to further develop this project please contact <joerg@higgsboson.tk>
|
9
|
+
Support sidekiq > 6.0, reference project capistrano-sidekiq, github: https://github.com/seuros/capistrano-sidekiq
|
13
10
|
|
14
11
|
# Getting Start
|
15
12
|
|
16
13
|
## Installation
|
17
14
|
|
18
|
-
|
15
|
+
```console
|
16
|
+
gem install mina-sidekiq
|
17
|
+
```
|
19
18
|
|
20
19
|
## Example
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
```ruby
|
22
|
+
require 'mina_sidekiq/tasks'
|
23
|
+
#...
|
24
|
+
|
25
|
+
task :setup do
|
26
|
+
# sidekiq needs a place to store its pid file and log file
|
27
|
+
command %(mkdir -p "#{fetch(:deploy_to)}/shared/pids/")
|
28
|
+
command %(mkdir -p "#{fetch(:deploy_to)}/shared/log/")
|
29
|
+
end
|
30
|
+
|
31
|
+
task :deploy do
|
32
|
+
deploy do
|
33
|
+
# stop accepting new workers
|
34
|
+
invoke :'git:clone'
|
35
|
+
invoke :'sidekiq:quiet'
|
36
|
+
invoke :'deploy:link_shared_paths'
|
25
37
|
...
|
26
|
-
# to make logs persistent between deploys
|
27
|
-
set :shared_paths, ['log']
|
28
38
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
queue! %[mkdir -p "#{deploy_to}/shared/log/"]
|
39
|
+
on :launch do
|
40
|
+
...
|
41
|
+
invoke :'sidekiq:restart'
|
33
42
|
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
```
|
46
|
+
## Support sidekiq > 6.0
|
47
|
+
|
48
|
+
Set init system to systemd in the mina deploy config:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
set :init_system, :systemd
|
52
|
+
```
|
53
|
+
|
54
|
+
Enable lingering for systemd user account
|
55
|
+
|
56
|
+
```
|
57
|
+
loginctl enable-linger USERACCOUNT
|
58
|
+
```
|
59
|
+
|
60
|
+
Install systemd.service template file and enable the service with:
|
61
|
+
|
62
|
+
```
|
63
|
+
bundle exec mina sidekiq:install
|
64
|
+
```
|
65
|
+
|
66
|
+
Default name for the service file is sidekiq-env.service. This can be changed as needed, for example:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
set :service_unit_name, "sidekiq-#{fetch(:rails_env)}.service"
|
70
|
+
```
|
71
|
+
|
72
|
+
Default systemctl command is ```systemctl --user```, this can be changed, for example:
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
set :systemctl_command, 'systemctl --user'
|
76
|
+
```
|
77
|
+
For non privileged user (non sudo) usage set up path for systemctl unit file:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
set :service_unit_path, '/home/www/.config/systemd/user'
|
81
|
+
```
|
82
|
+
|
83
|
+
where ```www``` is the username. For details see systemctl [doc page](https://www.freedesktop.org/software/systemd/man/systemd.unit.html)
|
84
|
+
|
85
|
+
To use systemctl integration with rbenv bundler path must be setted:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
set :bundler_path, '/home/www/.rbenv/shims/bundler'
|
89
|
+
```
|
90
|
+
|
91
|
+
To get bundler path use:
|
92
|
+
|
93
|
+
```bash
|
94
|
+
which bundler
|
95
|
+
```
|
96
|
+
|
97
|
+
|
98
|
+
## Integration with upstart
|
99
|
+
|
100
|
+
Set init system to upstart in the cap deploy config:
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
set :init_system, :upstart
|
104
|
+
```
|
105
|
+
|
106
|
+
Set upstart service name:
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
set :upstart_service_name, 'sidekiq'
|
110
|
+
```
|
34
111
|
|
35
|
-
task :deploy do
|
36
|
-
deploy do
|
37
|
-
# stop accepting new workers
|
38
|
-
invoke :'sidekiq:quiet'
|
39
|
-
invoke :'git:clone'
|
40
|
-
invoke :'deploy:link_shared_paths'
|
41
|
-
...
|
42
|
-
|
43
|
-
to :launch do
|
44
|
-
...
|
45
|
-
invoke :'sidekiq:restart'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
112
|
|
50
113
|
## Available Tasks
|
51
114
|
|
@@ -55,34 +118,44 @@ If you want to further develop this project please contact <joerg@higgsboson.tk>
|
|
55
118
|
* sidekiq:quiet
|
56
119
|
* sidekiq:log
|
57
120
|
|
121
|
+
sidekiq > 6.0
|
122
|
+
* sidekiq:install
|
123
|
+
* sidekiq:uninstall
|
124
|
+
|
58
125
|
## Available Options
|
59
126
|
|
60
|
-
| Option | Description
|
61
|
-
| ------------------- |
|
62
|
-
| *sidekiq* | Sets the path to sidekiq.
|
63
|
-
| *sidekiqctl* | Sets the path to sidekiqctl.
|
64
|
-
| *sidekiq\_timeout* | Sets a upper limit of time a worker is allowed to finish, before it is killed.
|
65
|
-
| *sidekiq\_log* | Sets the path to the log file of sidekiq.
|
66
|
-
| *sidekiq\_pid* | Sets the path to the pid file of a sidekiq worker.
|
67
|
-
| *sidekiq_processes* | Sets the number of sidekiq processes launched.
|
127
|
+
| Option | Description |
|
128
|
+
| ------------------- | ------------------------------------------------------------------------------------------------- |
|
129
|
+
| *sidekiq* | Sets the path to sidekiq. |
|
130
|
+
| *sidekiqctl* | Sets the path to sidekiqctl. |
|
131
|
+
| *sidekiq\_timeout* | Sets a upper limit of time a worker is allowed to finish, before it is killed. |
|
132
|
+
| *sidekiq\_log* | Sets the path to the log file of sidekiq. |
|
133
|
+
| *sidekiq\_pid* | Sets the path to the pid file of a sidekiq worker. |
|
134
|
+
| *sidekiq_processes* | Sets the number of sidekiq processes launched. |
|
135
|
+
| *sidekiq_config* | Sets the config file path. |
|
136
|
+
| *sidekiq_configs* | Sets the config file paths when using more than one sidekiq process with different configuration. |
|
68
137
|
|
69
138
|
## Testing
|
70
139
|
|
71
140
|
The test requires a local running ssh server with the ssh keys of the current
|
72
141
|
user added to its `~/.ssh/authorized_keys`. In OS X, this is "Remote Login"
|
73
|
-
under the Sharing pref pane.
|
142
|
+
under the Sharing pref pane. You will also need a working rvm installation.
|
74
143
|
|
75
144
|
To run the full blown test suite use:
|
76
145
|
|
77
|
-
|
146
|
+
```console
|
147
|
+
bundle exec rake test
|
148
|
+
```
|
78
149
|
|
79
150
|
For faster release cycle use
|
80
151
|
|
81
|
-
|
82
|
-
|
152
|
+
```console
|
153
|
+
cd test_env
|
154
|
+
bundle exec mina deploy --verbose
|
155
|
+
```
|
83
156
|
|
84
157
|
## Copyright
|
85
158
|
|
86
|
-
Copyright (c)
|
159
|
+
Copyright (c) 2016 Jörg Thalheim <joerg@higgsboson.tk>
|
87
160
|
|
88
161
|
See LICENSE for further details.
|
data/Rakefile
CHANGED
data/lib/mina_sidekiq/tasks.rb
CHANGED
@@ -4,15 +4,17 @@
|
|
4
4
|
# ## Usage example
|
5
5
|
# require 'mina_sidekiq/tasks'
|
6
6
|
# ...
|
7
|
+
|
7
8
|
# task :setup do
|
8
9
|
# # sidekiq needs a place to store its pid file
|
9
|
-
#
|
10
|
+
# command %[mkdir -p "#{fetch(:deploy_to)}/shared/pids/"]
|
10
11
|
# end
|
11
12
|
#
|
12
13
|
# task :deploy do
|
13
14
|
# deploy do
|
14
|
-
# invoke :'sidekiq:quiet'
|
15
15
|
# invoke :'git:clone'
|
16
|
+
# invoke :'sidekiq:quiet'
|
17
|
+
# invoke :'deploy:link_shared_paths'
|
16
18
|
# ...
|
17
19
|
#
|
18
20
|
# to :launch do
|
@@ -22,54 +24,71 @@
|
|
22
24
|
# end
|
23
25
|
# end
|
24
26
|
|
25
|
-
require 'mina/bundler'
|
26
|
-
require 'mina/rails'
|
27
|
-
|
28
27
|
# ## Settings
|
29
28
|
# Any and all of these settings can be overriden in your `deploy.rb`.
|
30
29
|
|
31
30
|
# ### sidekiq
|
32
31
|
# Sets the path to sidekiq.
|
33
|
-
|
32
|
+
set :sidekiq, -> { "#{fetch(:bundle_bin)} exec sidekiq" }
|
34
33
|
|
35
34
|
# ### sidekiqctl
|
36
35
|
# Sets the path to sidekiqctl.
|
37
|
-
|
36
|
+
set :sidekiqctl, -> { "#{fetch(:bundle_bin)} exec sidekiqctl" }
|
38
37
|
|
39
38
|
# ### sidekiq_timeout
|
40
39
|
# Sets a upper limit of time a process is allowed to finish, before it is killed by sidekiqctl.
|
41
|
-
|
40
|
+
set :sidekiq_timeout, 11
|
42
41
|
|
43
42
|
# ### sidekiq_config
|
44
|
-
# Sets the path to the configuration file of sidekiq
|
45
|
-
|
43
|
+
# Sets the path to the configuration file of sidekiq.
|
44
|
+
set :sidekiq_config, -> { "#{fetch(:current_path)}/config/sidekiq.yml" }
|
45
|
+
|
46
|
+
# ### sidekiq_configs
|
47
|
+
# A list of configuration file paths. Each file path will be assigned to one sidekiq
|
48
|
+
# instance in order. When specified sidekiq_config will be ignored.
|
49
|
+
set :sidekiq_configs, -> {
|
50
|
+
[
|
51
|
+
# "#{fetch(:current_path)}/config/sidekiq_1.yml",
|
52
|
+
# "#{fetch(:current_path)}/config/sidekiq_2.yml"
|
53
|
+
]
|
54
|
+
}
|
46
55
|
|
47
56
|
# ### sidekiq_log
|
48
57
|
# Sets the path to the log file of sidekiq
|
49
58
|
#
|
50
59
|
# To disable logging set it to "/dev/null"
|
51
|
-
|
60
|
+
set :sidekiq_log, -> { "#{fetch(:current_path)}/log/sidekiq.log" }
|
52
61
|
|
53
62
|
# ### sidekiq_pid
|
54
63
|
# Sets the path to the pid file of a sidekiq worker
|
55
|
-
|
64
|
+
set :sidekiq_pid, -> { "#{fetch(:shared_path)}/pids/sidekiq.pid" }
|
56
65
|
|
57
66
|
# ### sidekiq_processes
|
58
67
|
# Sets the number of sidekiq processes launched
|
59
|
-
|
68
|
+
set :sidekiq_processes, 1
|
60
69
|
|
61
70
|
# ### sidekiq_concurrency
|
62
71
|
# Sets the number of sidekiq threads per process (overrides value in sidekiq.yml)
|
63
|
-
|
72
|
+
set :sidekiq_concurrency, nil
|
73
|
+
|
74
|
+
set :sidekiq_user, nil
|
75
|
+
|
76
|
+
# Init system integration
|
77
|
+
set :init_system, -> { nil }
|
78
|
+
# systemd integration
|
79
|
+
set :service_unit_name, "sidekiq-#{fetch(:rails_env)}.service"
|
80
|
+
set :systemctl_command, 'systemctl --user'
|
81
|
+
|
82
|
+
set :upstart_service_name, "sidekiq"
|
64
83
|
|
65
84
|
# ## Control Tasks
|
66
85
|
namespace :sidekiq do
|
67
86
|
def for_each_process(&block)
|
68
|
-
sidekiq_processes.times do |idx|
|
87
|
+
fetch(:sidekiq_processes).times do |idx|
|
69
88
|
pid_file = if idx == 0
|
70
|
-
sidekiq_pid
|
89
|
+
fetch(:sidekiq_pid)
|
71
90
|
else
|
72
|
-
"#{sidekiq_pid}-#{idx}"
|
91
|
+
"#{fetch(:sidekiq_pid)}-#{idx}"
|
73
92
|
end
|
74
93
|
yield(pid_file, idx)
|
75
94
|
end
|
@@ -77,53 +96,135 @@ namespace :sidekiq do
|
|
77
96
|
|
78
97
|
# ### sidekiq:quiet
|
79
98
|
desc "Quiet sidekiq (stop accepting new work)"
|
80
|
-
task :quiet => :
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
99
|
+
task :quiet => :remote_environment do
|
100
|
+
comment 'Quiet sidekiq (stop accepting new work)'
|
101
|
+
case fetch(:init_system)
|
102
|
+
when :systemd
|
103
|
+
command %{ #{ fetch(:systemctl_command) } reload #{ fetch(:service_unit_name) } }
|
104
|
+
when :upstart
|
105
|
+
command %{ sudo service #{ fetch(:upstart_service_name) } reload }
|
106
|
+
else
|
107
|
+
in_path(fetch(:current_path)) do
|
108
|
+
for_each_process do |pid_file, idx|
|
109
|
+
command %{
|
110
|
+
if [ -f #{pid_file} ] && kill -0 `cat #{pid_file}` > /dev/null 2>&1; then
|
111
|
+
#{fetch(:sidekiqctl)} quiet #{pid_file}
|
112
|
+
else
|
113
|
+
echo 'Skip quiet command (no pid file found)'
|
114
|
+
fi
|
115
|
+
}.strip
|
116
|
+
end
|
117
|
+
end
|
91
118
|
end
|
92
119
|
end
|
93
120
|
|
94
121
|
# ### sidekiq:stop
|
95
122
|
desc "Stop sidekiq"
|
96
|
-
task :stop => :
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
123
|
+
task :stop => :remote_environment do
|
124
|
+
comment 'Stop sidekiq'
|
125
|
+
case fetch(:init_system)
|
126
|
+
when :systemd
|
127
|
+
command %{ #{ fetch(:systemctl_command) } stop #{ fetch(:service_unit_name) } }
|
128
|
+
when :upstart
|
129
|
+
command %{ sudo service #{ fetch(:upstart_service_name) } stop }
|
130
|
+
else
|
131
|
+
in_path(fetch(:current_path)) do
|
132
|
+
for_each_process do |pid_file, idx|
|
133
|
+
command %{
|
134
|
+
if [ -f #{pid_file} ] && kill -0 `cat #{pid_file}`> /dev/null 2>&1; then
|
135
|
+
#{fetch(:sidekiqctl)} stop #{pid_file} #{fetch(:sidekiq_timeout)}
|
136
|
+
else
|
137
|
+
echo 'Skip stopping sidekiq (no pid file found)'
|
138
|
+
fi
|
139
|
+
}.strip
|
140
|
+
end
|
141
|
+
end
|
107
142
|
end
|
108
143
|
end
|
109
144
|
|
110
145
|
# ### sidekiq:start
|
111
146
|
desc "Start sidekiq"
|
112
|
-
task :start => :
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
147
|
+
task :start => :remote_environment do
|
148
|
+
comment 'Start sidekiq'
|
149
|
+
case fetch(:init_system)
|
150
|
+
when :systemd
|
151
|
+
command %{ #{ fetch(:systemctl_command) } start #{ fetch(:service_unit_name) } }
|
152
|
+
when :upstart
|
153
|
+
command %{ sudo service #{ fetch(:upstart_service_name) } start }
|
154
|
+
else
|
155
|
+
in_path(fetch(:current_path)) do
|
156
|
+
for_each_process do |pid_file, idx|
|
157
|
+
sidekiq_config = fetch(:sidekiq_configs)[idx] || fetch(:sidekiq_config)
|
158
|
+
sidekiq_concurrency = fetch(:sidekiq_concurrency)
|
159
|
+
concurrency_arg = if sidekiq_concurrency.nil?
|
160
|
+
""
|
161
|
+
else
|
162
|
+
"-c #{sidekiq_concurrency}"
|
163
|
+
end
|
164
|
+
command_line = %[#{fetch(:sidekiq)} -d -e #{fetch(:rails_env)} #{concurrency_arg} -C #{sidekiq_config} -i #{idx} -P #{pid_file}]
|
165
|
+
command_line += " -L #{fetch(:sidekiq_log)}" if fetch(:sidekiq_log)
|
166
|
+
|
167
|
+
command command_line
|
168
|
+
end
|
169
|
+
end
|
124
170
|
end
|
125
171
|
end
|
126
172
|
|
173
|
+
task :install do
|
174
|
+
case fetch(:init_system)
|
175
|
+
when :systemd
|
176
|
+
create_systemd_template
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
task :uninstall do
|
181
|
+
case fetch(:init_system)
|
182
|
+
when :systemd
|
183
|
+
command %{ #{ fetch(:systemctl_command) } disable #{fetch(:service_unit_name)} }
|
184
|
+
command %{ rm #{File.join(fetch(:service_unit_path, fetch_systemd_unit_path),fetch(:service_unit_name))} }
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def create_systemd_template
|
189
|
+
template = %{
|
190
|
+
[Unit]
|
191
|
+
Description=sidekiq for #{fetch(:application)} #{fetch(:app_name)}
|
192
|
+
After=syslog.target network.target
|
193
|
+
|
194
|
+
[Service]
|
195
|
+
Type=simple
|
196
|
+
Environment=RAILS_ENV=#{ fetch(:rails_env) }
|
197
|
+
StandardOutput=append:#{fetch(:deploy_to)}/current/log/sidekiq.log
|
198
|
+
StandardError=append:#{fetch(:deploy_to)}/current/log/sidekiq.log
|
199
|
+
WorkingDirectory=#{fetch(:deploy_to)}/current
|
200
|
+
ExecStart=#{fetch(:bundler_path, '/usr/local/bin/bundler')} exec sidekiq -e #{fetch(:rails_env)}
|
201
|
+
ExecReload=/bin/kill -TSTP $MAINPID
|
202
|
+
ExecStop=/bin/kill -TERM $MAINPID
|
203
|
+
RestartSec=1
|
204
|
+
Restart=on-failure
|
205
|
+
|
206
|
+
SyslogIdentifier=sidekiq
|
207
|
+
|
208
|
+
[Install]
|
209
|
+
WantedBy=default.target
|
210
|
+
}
|
211
|
+
systemd_path = fetch(:service_unit_path, fetch_systemd_unit_path)
|
212
|
+
service_path = systemd_path + "/" + fetch(:service_unit_name)
|
213
|
+
comment %{Creating systemctl unit file}
|
214
|
+
command %{ mkdir -p #{systemd_path} }
|
215
|
+
command %{ touch #{service_path} }
|
216
|
+
command %{ echo "#{ template }" > #{ service_path } }
|
217
|
+
comment %{Reloading systemctl daemon}
|
218
|
+
command %{ #{ fetch(:systemctl_command) } daemon-reload }
|
219
|
+
comment %{Enabling sidekiq service}
|
220
|
+
command %{ #{ fetch(:systemctl_command) } enable #{ service_path } }
|
221
|
+
end
|
222
|
+
|
223
|
+
def fetch_systemd_unit_path
|
224
|
+
home_dir = '/usr'
|
225
|
+
File.join(home_dir, "lib", "systemd", "user")
|
226
|
+
end
|
227
|
+
|
127
228
|
# ### sidekiq:restart
|
128
229
|
desc "Restart sidekiq"
|
129
230
|
task :restart do
|
@@ -132,8 +233,8 @@ namespace :sidekiq do
|
|
132
233
|
end
|
133
234
|
|
134
235
|
desc "Tail log from server"
|
135
|
-
task :log => :
|
136
|
-
|
236
|
+
task :log => :remote_environment do
|
237
|
+
command %[tail -f #{fetch(:sidekiq_log)}]
|
137
238
|
end
|
138
239
|
|
139
240
|
end
|
data/lib/mina_sidekiq/version.rb
CHANGED
data/mina-sidekiq.gemspec
CHANGED
@@ -16,13 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
|
-
s.post_install_message = <<-MESSAGE
|
20
|
-
Starting with 0.2.0, you have to add:
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
MESSAGE
|
26
|
-
|
27
|
-
s.add_runtime_dependency "mina"
|
20
|
+
s.add_runtime_dependency 'mina', '>= 1.0.2'
|
21
|
+
s.add_development_dependency 'pry-byebug'
|
22
|
+
s.add_development_dependency 'minitest'
|
28
23
|
end
|
data/test/deploy_test.rb
CHANGED
@@ -16,6 +16,7 @@ describe "mina_sidekiq" do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def check_process(pid)
|
19
|
+
pid = pid.to_i
|
19
20
|
begin
|
20
21
|
Process.kill(0, pid)
|
21
22
|
return true
|
@@ -40,7 +41,7 @@ describe "mina_sidekiq" do
|
|
40
41
|
mina "deploy"
|
41
42
|
rescue Exception => e
|
42
43
|
log = "./deploy/shared/sidekiq.log"
|
43
|
-
if File.
|
44
|
+
if File.exist?(log)
|
44
45
|
puts "cat #{log}"
|
45
46
|
puts File.open(log).read
|
46
47
|
end
|
@@ -50,12 +51,13 @@ describe "mina_sidekiq" do
|
|
50
51
|
it "should start/stop sidekiq" do
|
51
52
|
sidekiq_pid_path = @env_root.join("deploy", "shared", "pids", "sidekiq.pid")
|
52
53
|
# fresh deploy
|
54
|
+
mina "deploy"
|
53
55
|
mina "sidekiq:start"
|
54
56
|
pid = File.read(sidekiq_pid_path)
|
55
57
|
check_process(pid).must_equal true
|
56
58
|
# second deploy
|
57
59
|
mina "sidekiq:stop"
|
58
|
-
check_process(pid).must_equal
|
60
|
+
check_process(pid).must_equal false
|
59
61
|
end
|
60
62
|
end
|
61
63
|
end
|
data/test/test_helper.rb
CHANGED
data/test_env/config/deploy.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
|
-
require 'mina'
|
1
|
+
require 'mina/rails'
|
2
2
|
require 'mina/git'
|
3
|
-
require 'mina_sidekiq/tasks'
|
4
|
-
require 'mina/git'
|
5
|
-
require 'mina/bundler'
|
6
3
|
require 'mina/rvm'
|
4
|
+
require 'mina_sidekiq/tasks'
|
7
5
|
require 'fileutils'
|
8
6
|
|
9
|
-
|
10
7
|
FileUtils.mkdir_p "#{Dir.pwd}/deploy"
|
11
8
|
|
12
9
|
set :ssh_options, '-o StrictHostKeyChecking=no'
|
@@ -17,31 +14,29 @@ set :repository, 'https://github.com/Mic92/mina-sidekiq-test-rails.git'
|
|
17
14
|
set :keep_releases, 2
|
18
15
|
set :sidekiq_processes, 2
|
19
16
|
|
20
|
-
|
21
|
-
|
22
|
-
task :environment do
|
23
|
-
invoke :'rvm:use[ruby-2.1.2]'
|
17
|
+
task :remote_environment do
|
18
|
+
invoke :'rvm:use', ENV.fetch('RUBY_VERSION', 'ruby-2.3.1')
|
24
19
|
end
|
25
20
|
|
26
|
-
task setup: :
|
27
|
-
|
28
|
-
|
21
|
+
task setup: :remote_environment do
|
22
|
+
command %(mkdir -p "#{fetch(:deploy_to)}/shared/pids/")
|
23
|
+
command %(mkdir -p "#{fetch(:deploy_to)}/shared/log/")
|
29
24
|
end
|
30
25
|
|
31
|
-
task deploy
|
26
|
+
task :deploy do
|
32
27
|
deploy do
|
33
28
|
invoke :'git:clone'
|
34
29
|
invoke :'deploy:link_shared_paths'
|
35
30
|
invoke :'bundle:install'
|
36
31
|
|
37
|
-
|
32
|
+
on :launch do
|
38
33
|
invoke :'sidekiq:start'
|
39
|
-
|
34
|
+
command %(sleep 3; kill -0 `cat #{fetch(:sidekiq_pid)}`)
|
40
35
|
|
41
36
|
invoke :'sidekiq:quiet'
|
42
37
|
|
43
38
|
invoke :'sidekiq:stop'
|
44
|
-
|
39
|
+
command %((kill -0 `cat #{fetch(:sidekiq_pid)}`) 2> /dev/null && exit 1 || exit 0)
|
45
40
|
end
|
46
41
|
end
|
47
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mina-sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joerg Thalheim
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 1980-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mina
|
@@ -16,9 +16,37 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry-byebug
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
22
50
|
version_requirements: !ruby/object:Gem::Requirement
|
23
51
|
requirements:
|
24
52
|
- - ">="
|
@@ -35,7 +63,6 @@ files:
|
|
35
63
|
- ".travis.yml"
|
36
64
|
- Changelog.md
|
37
65
|
- Gemfile
|
38
|
-
- Gemfile.lock
|
39
66
|
- LICENSE
|
40
67
|
- README.md
|
41
68
|
- Rakefile
|
@@ -50,12 +77,7 @@ homepage: http://github.com/Mic92/mina-sidekiq
|
|
50
77
|
licenses:
|
51
78
|
- MIT
|
52
79
|
metadata: {}
|
53
|
-
post_install_message:
|
54
|
-
Starting with 0.2.0, you have to add:
|
55
|
-
|
56
|
-
require "mina_sidekiq/tasks"
|
57
|
-
|
58
|
-
in your deploy.rb to load the library
|
80
|
+
post_install_message:
|
59
81
|
rdoc_options: []
|
60
82
|
require_paths:
|
61
83
|
- lib
|
@@ -70,12 +92,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
92
|
- !ruby/object:Gem::Version
|
71
93
|
version: '0'
|
72
94
|
requirements: []
|
73
|
-
|
74
|
-
|
75
|
-
signing_key:
|
95
|
+
rubygems_version: 3.1.3
|
96
|
+
signing_key:
|
76
97
|
specification_version: 4
|
77
98
|
summary: Tasks to deploy Sidekiq with mina.
|
78
99
|
test_files:
|
79
100
|
- test/deploy_test.rb
|
80
101
|
- test/test_helper.rb
|
81
|
-
has_rdoc:
|
data/Gemfile.lock
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
mina-sidekiq (0.3.1)
|
5
|
-
mina
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://www.rubygems.org/
|
9
|
-
specs:
|
10
|
-
mina (0.3.1)
|
11
|
-
open4 (~> 1.3.4)
|
12
|
-
rake
|
13
|
-
open4 (1.3.4)
|
14
|
-
rake (10.4.2)
|
15
|
-
|
16
|
-
PLATFORMS
|
17
|
-
ruby
|
18
|
-
|
19
|
-
DEPENDENCIES
|
20
|
-
mina-sidekiq!
|