sidekiq-runner 0.1.1 → 0.1.3

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
2
  SHA1:
3
- metadata.gz: 4b7fa70811b720ebc2ab7a34f674df39ce1f2816
4
- data.tar.gz: 61bbd1e7ba1e5b094f0b0b4dd3b9b8f2cef8cde9
3
+ metadata.gz: bc538d49e4cd0c3dbd72dd4b32d124c427fe60c1
4
+ data.tar.gz: e9753e622a05176942872caa99ea4397fe3d9ff2
5
5
  SHA512:
6
- metadata.gz: 1e15d46d709d85d15832e1595a0601ffc77c7cc60b71dda140a5d92fa9d2644252c46f84e04e594f9880799f6680a9c0b68b00ba5455c5370479eaa6de1a6f7d
7
- data.tar.gz: 9728647c72592024dba383849ded7f4ed3dc658ceb28cb09b944a7926f9314d0518422441b06a12e7dcb3690b009ec2363b546bb6ec746bf5d5c1edbaa29e211
6
+ metadata.gz: d511179b7968501b3a169969fcc3c53fc56950e8b1ef18ac9181f55d6a3b1921e78d5bad422f9cb00f465efef103c37fb0ea76e0abeaa4ffe7dff1016a01db8b
7
+ data.tar.gz: 7203ffee3f9de1de0ff87871bdfd8b0c419b6dfa4b58b92f8fb6da58478a1e58891b34eef1f5b06934a6ca1c4f9f5514945c5dc36d09d45885a975f4cb3e32f4
@@ -15,13 +15,14 @@ module SidekiqRunner
15
15
  RUNNER_ATTRIBUTES = [:config_file, :daemonize, :port, :syslog, :events]
16
16
  RUNNER_ATTRIBUTES.each { |att| attr_accessor att }
17
17
 
18
- CONFIG_FILE_ATTRIBUTES = [:process_name, :interval, :stop_timeout, :log_file]
18
+ CONFIG_FILE_ATTRIBUTES = [:process_name, :interval, :stop_timeout, :log_file, :maximum_memory_usage]
19
19
  CONFIG_FILE_ATTRIBUTES.each { |att| attr_accessor att }
20
20
 
21
21
  def initialize
22
22
  @process_name = 'sidekiq'
23
23
  @interval = 30
24
24
  @stop_timeout = 30
25
+ @maximum_memory_usage = nil
25
26
 
26
27
  @log_file = File.join(Dir.pwd, 'log', 'god.log')
27
28
  @config_file = File.join(Dir.pwd, 'config', 'god.yml')
@@ -61,6 +61,17 @@ sidekiq_config.each do |name, skiq|
61
61
  end
62
62
  end
63
63
 
64
+ # Monitor process memory usage.
65
+ if god_config.maximum_memory_usage
66
+ w.restart_if do |restart|
67
+ restart.condition(:memory_usage) do |c|
68
+ c.above = god_config.maximum_memory_usage.to_i.megabytes
69
+ c.times = 3
70
+ c.interval = god_config.interval
71
+ end
72
+ end
73
+ end
74
+
64
75
  w.lifecycle do |on|
65
76
  on.condition(:flapping) do |c|
66
77
  c.to_state = [:start, :restart] # If this watch is started or restarted...
@@ -4,7 +4,7 @@ module SidekiqRunner
4
4
  RUNNER_ATTRIBUTES = [:bundle_env, :chdir, :requirefile]
5
5
  RUNNER_ATTRIBUTES.each { |att| attr_accessor att }
6
6
 
7
- CONFIG_FILE_ATTRIBUTES = [:concurrency, :verbose, :pidfile, :logfile, :tag]
7
+ CONFIG_FILE_ATTRIBUTES = [:concurrency, :verbose, :pidfile, :logfile, :tag, :rbtrace]
8
8
  CONFIG_FILE_ATTRIBUTES.each { |att| attr_accessor att }
9
9
 
10
10
  attr_reader :name, :queues
@@ -23,6 +23,7 @@ module SidekiqRunner
23
23
  @concurrency = 4
24
24
  @verbose = false
25
25
  @tag = name
26
+ @rbtrace = false
26
27
  end
27
28
 
28
29
  def add_queue(queue_name, weight = 1)
@@ -57,7 +58,8 @@ module SidekiqRunner
57
58
  create_directories!
58
59
 
59
60
  cmd = []
60
- cmd << (bundle_env ? 'bundle exec sidekiq' : 'sidekiq')
61
+ cmd << 'bundle exec' if bundle_env
62
+ cmd << (rbtrace ? File.expand_path('../../../script/sidekiq_rbtrace', __FILE__) : 'sidekiq')
61
63
  cmd << '-d'
62
64
  cmd << "-c #{concurrency}"
63
65
  cmd << '-v' if verbose
@@ -1,3 +1,3 @@
1
1
  module SidekiqRunner
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rbtrace'
4
+
5
+ def sidekiq_bin
6
+ require 'sidekiq/cli'
7
+
8
+ begin
9
+ cli = Sidekiq::CLI.instance
10
+ cli.parse
11
+ cli.run
12
+ rescue => e
13
+ raise e if $DEBUG
14
+ STDERR.puts e.message
15
+ STDERR.puts e.backtrace.join("\n")
16
+ exit 1
17
+ end
18
+ end
19
+
20
+ sidekiq = `which sidekiq` rescue ''
21
+ if sidekiq.empty?
22
+ # When we can't locate the Sidekiq executable, mimick
23
+ # its behaviour here.
24
+ sidekiq_bin
25
+ else
26
+ begin
27
+ # Otherwise load the sidekiq executable.
28
+ load sidekiq.strip
29
+ rescue
30
+ sidekiq_bin
31
+ end
32
+ end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - FlavourSys Technology GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-01 00:00:00.000000000 Z
11
+ date: 2015-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
15
- requirement: !ruby/object:Gem::Requirement
14
+ version_requirements: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
18
  version: '10.3'
20
- type: :runtime
19
+ name: rake
21
20
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
21
+ requirement: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
25
  version: '10.3'
26
+ type: :runtime
27
27
  - !ruby/object:Gem::Dependency
28
- name: god
29
- requirement: !ruby/object:Gem::Requirement
28
+ version_requirements: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
32
  version: '0.13'
34
- type: :runtime
33
+ name: god
35
34
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
35
+ requirement: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0.13'
40
+ type: :runtime
41
41
  description: Provide an easy way to configure, start, and monitor all your Sidekiq
42
42
  processes
43
43
  email: technology@flavoursys.com
@@ -52,6 +52,7 @@ files:
52
52
  - lib/sidekiq-runner/sidekiq_instance.rb
53
53
  - lib/sidekiq-runner/tasks.rb
54
54
  - lib/sidekiq-runner/version.rb
55
+ - script/sidekiq_rbtrace
55
56
  homepage: https://github.com/FlavourSys/sidekiq-runner
56
57
  licenses:
57
58
  - MIT
@@ -72,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
73
  version: '0'
73
74
  requirements: []
74
75
  rubyforge_project:
75
- rubygems_version: 2.2.2
76
+ rubygems_version: 2.4.5
76
77
  signing_key:
77
78
  specification_version: 4
78
79
  summary: Sidekiq configuration and rake tasks