mina-sidekiq 0.4.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f110d06a373caf157e7ad1ab5813aa8d567bfffd
4
- data.tar.gz: f00cd8d8d44198bb991c70d0748dad73042c1448
2
+ SHA256:
3
+ metadata.gz: b6b58dc398da8db743c4f5f063cf60cabc54e546463c8ca9504afed5855ee4a5
4
+ data.tar.gz: 46cd45d6d4ef1ab10a93892baf0fab90d7899b4520e2afd1a068e0fb90ab7dae
5
5
  SHA512:
6
- metadata.gz: 09813f8ebdb01e318e6c547e756a7fd3bbb9180c21d66d229cf8228c80b4eadf9e0af69b104597b6162798ef339b5ed2d6b42f97f07d75cad945b9c8085cb5d4
7
- data.tar.gz: 5f1a6964a8204656b6a9bab472e4fdac368321550248ac01845d84281cf565e84d09ce725009882507f1423ce557182034985f57fd2728affc4a36e148b13644
6
+ metadata.gz: d8902d7d2b9f28020b5049dcaf661fbf7ab07b644b9e4da7a5b737a628acbd38de5480386bd281430a9fbc7d3c7c28f7e4d63a48cd10030805b89af9bd18feee
7
+ data.tar.gz: dbff1c1aea66bb4a111e29fc3c9f5c368d22819b0e7e9329d558f99cefa9ce4bc199bc2bd8035ccd1b7b23b68f7a9fc7df5e1c9a3e2b5fd69b0f8aedf43a9f79
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
- sudo: false
2
+ cache: bundler
3
3
  rvm:
4
- - "1.9.3"
5
- - "2.0.0"
6
- - "2.1.0"
7
- services: redis
8
- env: FORCE_ADD_SSH_KEY=1
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
@@ -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
@@ -1,3 +1,5 @@
1
- source "http://www.rubygems.org"
1
+ source "https://www.rubygems.org"
2
+
3
+ gem "rake"
2
4
 
3
5
  gemspec
data/README.md CHANGED
@@ -1,51 +1,114 @@
1
1
  mina-sidekiq
2
2
  ============
3
3
 
4
- [![Build Status](https://travis-ci.org/Mic92/mina-sidekiq.png?branch=master)](https://travis-ci.org/Mic92/mina-sidekiq)
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
- mina-sidekiq is a gem that adds tasks to aid in the deployment of [Sidekiq] (http://mperham.github.com/sidekiq/)
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
- ##CURRENTLY UNMAINTAINED
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
- gem install mina-sidekiq
15
+ ```console
16
+ gem install mina-sidekiq
17
+ ```
19
18
 
20
19
  ## Example
21
20
 
22
- ## Usage example
23
-
24
- require 'mina_sidekiq/tasks'
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
- task :setup do
30
- # sidekiq needs a place to store its pid file and log file
31
- queue! %[mkdir -p "#{deploy_to}/shared/pids/"]
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
- bundle exec rake test
146
+ ```console
147
+ bundle exec rake test
148
+ ```
78
149
 
79
150
  For faster release cycle use
80
151
 
81
- cd test_env
82
- bundle exec mina deploy --verbose
152
+ ```console
153
+ cd test_env
154
+ bundle exec mina deploy --verbose
155
+ ```
83
156
 
84
157
  ## Copyright
85
158
 
86
- Copyright (c) 2013 Jörg Thalheim http://higgsboson.tk/joerg
159
+ Copyright (c) 2016 Jörg Thalheim <joerg@higgsboson.tk>
87
160
 
88
161
  See LICENSE for further details.
data/Rakefile CHANGED
@@ -1,5 +1,4 @@
1
- require "rake"
2
- require "rake/testtask"
1
+ require 'rake/testtask'
3
2
 
4
3
  Rake::TestTask.new do |t|
5
4
  t.libs << "test"
@@ -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
- # queue! %[mkdir -p "#{deploy_to}/shared/pids/"]
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
- set_default :sidekiq, lambda { "#{bundle_bin} exec sidekiq" }
32
+ set :sidekiq, -> { "#{fetch(:bundle_bin)} exec sidekiq" }
34
33
 
35
34
  # ### sidekiqctl
36
35
  # Sets the path to sidekiqctl.
37
- set_default :sidekiqctl, lambda { "#{bundle_prefix} sidekiqctl" }
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
- set_default :sidekiq_timeout, 11
40
+ set :sidekiq_timeout, 11
42
41
 
43
42
  # ### sidekiq_config
44
- # Sets the path to the configuration file of sidekiq
45
- set_default :sidekiq_config, lambda { "#{deploy_to}/#{current_path}/config/sidekiq.yml" }
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
- set_default :sidekiq_log, lambda { "#{deploy_to}/#{current_path}/log/sidekiq.log" }
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
- set_default :sidekiq_pid, lambda { "#{deploy_to}/#{shared_path}/pids/sidekiq.pid" }
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
- set_default :sidekiq_processes, 1
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
- set_default :sidekiq_concurrency, nil
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 => :environment do
81
- queue %[echo "-----> Quiet sidekiq (stop accepting new work)"]
82
- for_each_process do |pid_file, idx|
83
- queue %{
84
- if [ -f #{pid_file} ] && kill -0 `cat #{pid_file}`> /dev/null 2>&1; then
85
- cd "#{deploy_to}/#{current_path}"
86
- #{echo_cmd %{#{sidekiqctl} quiet #{pid_file}} }
87
- else
88
- echo 'Skip quiet command (no pid file found)'
89
- fi
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 => :environment do
97
- queue %[echo "-----> Stop sidekiq"]
98
- for_each_process do |pid_file, idx|
99
- queue %[
100
- if [ -f #{pid_file} ] && kill -0 `cat #{pid_file}`> /dev/null 2>&1; then
101
- cd "#{deploy_to}/#{current_path}"
102
- #{echo_cmd %[#{sidekiqctl} stop #{pid_file} #{sidekiq_timeout}]}
103
- else
104
- echo 'Skip stopping sidekiq (no pid file found)'
105
- fi
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 => :environment do
113
- queue %[echo "-----> Start sidekiq"]
114
- for_each_process do |pid_file, idx|
115
- concurrency_arg = if sidekiq_concurrency.nil?
116
- ""
117
- else
118
- "-c #{sidekiq_concurrency}"
119
- end
120
- queue %{
121
- cd "#{deploy_to}/#{current_path}"
122
- #{echo_cmd %[#{sidekiq} -d -e #{rails_env} #{concurrency_arg} -C #{sidekiq_config} -i #{idx} -P #{pid_file} -L #{sidekiq_log}] }
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 => :environment do
136
- queue %[tail -f #{sidekiq_log}]
236
+ task :log => :remote_environment do
237
+ command %[tail -f #{fetch(:sidekiq_log)}]
137
238
  end
138
239
 
139
240
  end
@@ -1,5 +1,5 @@
1
1
  module MinaSidekiq
2
2
  def self.version
3
- "0.4.1"
3
+ '1.1.0'
4
4
  end
5
5
  end
@@ -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
- require "mina_sidekiq/tasks"
23
-
24
- in your deploy.rb to load the library
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
@@ -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.exists?(log)
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 true
60
+ check_process(pid).must_equal false
59
61
  end
60
62
  end
61
63
  end
@@ -1,4 +1,3 @@
1
- require "minitest/spec"
2
1
  require "minitest/autorun"
3
2
  require 'pathname'
4
3
 
@@ -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
- set :shared_paths, ['log']
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: :environment do
27
- queue! %[mkdir -p "#{deploy_to}/shared/pids/"]
28
- queue! %[mkdir -p "#{deploy_to}/shared/log/"]
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: :environment do
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
- to :launch do
32
+ on :launch do
38
33
  invoke :'sidekiq:start'
39
- queue! %[sleep 3; kill -0 `cat #{sidekiq_pid}`]
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
- queue! %[(kill -0 `cat #{sidekiq_pid}`) 2> /dev/null && exit 1 || exit 0]
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: 0.4.1
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: 2016-06-27 00:00:00.000000000 Z
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: '0'
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
- rubyforge_project:
74
- rubygems_version: 2.5.1
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:
@@ -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!