eivo-rails-sidekiq 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f0694ae24821eb6693e42c121ff20f3b257fe15e
4
+ data.tar.gz: e39a7aafdd14097767be03d2aabda3873ec4cd13
5
+ SHA512:
6
+ metadata.gz: 46b3aab6bd42bd49540b0ebefa099857cd8ba6a8656c05e9189a9608ea873db0ff594221bcf2812e679b5a952417dab7a678e0c182fbe5d3661c3147f967e585
7
+ data.tar.gz: 6a774f83c3c8b4b5fba23328a8dfe6e5ce25a9065a919d64483cc7b6d1085ec35b0117d0ec2e48b1e6f60b8a29ebb78c6e957d4c26f76b75134b6a89b510478d
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ /.bundle/
3
+ /pkg/
4
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2019 Jonathan VUKOVICH-TRIBOUHARET
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # EIVO Rails Sidekiq
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'eivo-rails-sidekiq'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install eivo-sidekiq -N
18
+
19
+ ## Usage
20
+
21
+ $ rails g eivo:sidekiq:install
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'sidekiq'
4
+ require 'redis-namespace'
5
+ require 'hiredis'
6
+
7
+ redis_config = {
8
+ url: ENV.fetch('REDIS_URL') { 'redis://localhost:6379/0' },
9
+ namespace: "#{Rails.application.class.parent_name.parameterize}-#{Rails.env}",
10
+ driver: 'hiredis'
11
+ }
12
+
13
+ Sidekiq.configure_client do |config|
14
+ config.redis = redis_config.dup
15
+ end
16
+
17
+ Sidekiq.configure_server do |config|
18
+ config.redis = redis_config.dup
19
+ end
20
+
21
+ ActiveJob::Base.queue_adapter = :sidekiq if defined?(ActiveJob)
@@ -0,0 +1,25 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'eivo-rails-sidekiq'
5
+ spec.version = '0.0.1'
6
+ spec.authors = ['Jonathan VUKOVICH-TRIBOUHARET']
7
+ spec.email = ['jonathan@eivo.co']
8
+
9
+ spec.summary = 'EIVO Rails Sidekiq'
10
+ spec.description = 'EIVO Rails Sidekiq'
11
+ spec.homepage = 'https://www.eivo.co'
12
+ spec.license = 'MIT'
13
+
14
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
15
+ `git ls-files -z`.split("\x0")
16
+ end
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_dependency 'sidekiq'
20
+ spec.add_dependency 'redis-namespace'
21
+ spec.add_dependency 'hiredis'
22
+
23
+ spec.add_development_dependency 'bundler'
24
+ spec.add_development_dependency 'rake'
25
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EIVO
4
+ module Sidekiq
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1 @@
1
+ require_relative 'eivo-rails-sidekiq/engine'
@@ -0,0 +1,3 @@
1
+ Initialize default files
2
+
3
+ rails g eivo:sidekiq:install
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators'
4
+
5
+ module EIVO
6
+ module Sidekiq
7
+ class InstallGenerator < Rails::Generators::Base
8
+
9
+ source_root File.expand_path('../templates', __FILE__)
10
+
11
+ def self.namespace(name = nil)
12
+ @namespace ||= super.sub('e_i_v_o', 'eivo')
13
+ end
14
+
15
+ def create_initializer_file
16
+ copy_file 'config/sidekiq.yml'
17
+ copy_file 'app/jobs/application_job.rb'
18
+
19
+ restart_code = <<-'EOF'
20
+ ### EIVO Sidekiq begin ###
21
+
22
+ bundle exec sidekiqctl stop tmp/pids/sidekiq.pid 120
23
+ bundle exec sidekiq -C config/sidekiq.yml
24
+
25
+ ### EIVO Sidekiq end ###
26
+ EOF
27
+
28
+ stop_code = <<-'EOF'
29
+ ### EIVO Sidekiq begin ###
30
+
31
+ bundle exec sidekiqctl stop tmp/pids/sidekiq.pid 15
32
+
33
+ ### EIVO Sidekiq end ###
34
+ EOF
35
+
36
+ # Remove old code if present
37
+ regexp = /\n### EIVO Sidekiq begin ###.*### EIVO Sidekiq end ###/m
38
+ gsub_file 'restart_production.sh', regexp, ''
39
+ gsub_file 'restart_staging.sh', regexp, ''
40
+ gsub_file 'stop_production.sh', regexp, ''
41
+ gsub_file 'stop_staging.sh', regexp, ''
42
+
43
+ # Inject new code
44
+ after = "### EIVO end ###\n"
45
+ inject_into_file 'restart_production.sh', restart_code, after: after
46
+ inject_into_file 'restart_staging.sh', restart_code, after: after
47
+ inject_into_file 'stop_production.sh', stop_code, after: after
48
+ inject_into_file 'stop_staging.sh', stop_code, after: after
49
+
50
+ append_to_file 'Procfile', "worker: bundle exec sidekiq -C config/sidekiq.yml\n"
51
+ append_to_file '.env.example', "SIDEKIQ_THREADS=\"5\"\n"
52
+ gsub_file '.env.example', /^DB_POOL="(\d+)".*/, 'DB_POOL="\1" # [RAILS_MAX_THREADS, SIDEKIQ_THREADS].max'
53
+ end
54
+
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationJob
2
+ include Sidekiq::Worker
3
+ end
@@ -0,0 +1,11 @@
1
+ :concurrency: <%= ENV.fetch('SIDEKIQ_THREADS') { 5 } %>
2
+ staging:
3
+ :daemon: true
4
+ :pidfile: tmp/pids/sidekiq-staging.pid
5
+ :logfile: log/sidekiq-staging.log
6
+ production:
7
+ :daemon: true
8
+ :pidfile: tmp/pids/sidekiq.pid
9
+ :logfile: log/sidekiq.log
10
+ :queues:
11
+ - default
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eivo-rails-sidekiq
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan VUKOVICH-TRIBOUHARET
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-06-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sidekiq
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: redis-namespace
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: hiredis
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: EIVO Rails Sidekiq
84
+ email:
85
+ - jonathan@eivo.co
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE
93
+ - README.md
94
+ - Rakefile
95
+ - config/initializers/sidekiq.rb
96
+ - eivo-rails-sidekiq.gemspec
97
+ - lib/eivo-rails-sidekiq.rb
98
+ - lib/eivo-rails-sidekiq/engine.rb
99
+ - lib/generators/eivo/sidekiq/USAGE
100
+ - lib/generators/eivo/sidekiq/install_generator.rb
101
+ - lib/generators/eivo/sidekiq/templates/app/jobs/application_job.rb
102
+ - lib/generators/eivo/sidekiq/templates/config/sidekiq.yml
103
+ homepage: https://www.eivo.co
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.4.5
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: EIVO Rails Sidekiq
127
+ test_files: []