pixelforce_recipes 3.9.2 → 4.0.3

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile.lock +237 -26
  4. data/app/controllers/admin/api/admin_base_controller.rb +110 -0
  5. data/app/controllers/admin/api/app_versions_controller.rb +26 -0
  6. data/app/controllers/admin/api/available_modules_controller.rb +20 -0
  7. data/app/controllers/api/base_controller.rb +74 -0
  8. data/app/controllers/api/v1/health_check_controller.rb +12 -0
  9. data/app/controllers/application_controller.rb +10 -0
  10. data/app/controllers/auth/passwords_controller.rb +7 -0
  11. data/app/controllers/concerns/.keep +0 -0
  12. data/app/controllers/concerns/exception_handler.rb +54 -0
  13. data/app/controllers/concerns/request_header_handler.rb +35 -0
  14. data/app/controllers/concerns/response_handler.rb +51 -0
  15. data/app/controllers/pages_controller.rb +36 -0
  16. data/app/controllers/users_controller.rb +3 -0
  17. data/lib/pixelforce_recipes/engine.rb +5 -0
  18. data/lib/pixelforce_recipes/railtie.rb +4 -0
  19. data/lib/pixelforce_recipes/{capistrano_3_recipes → recipes/capistrano_recipes}/elbas.rb +1 -1
  20. data/lib/pixelforce_recipes/recipes.rb +4 -0
  21. data/lib/pixelforce_recipes/version.rb +1 -1
  22. data/lib/pixelforce_recipes.rb +7 -9
  23. data/pixelforce_recipes.gemspec +4 -2
  24. metadata +74 -37
  25. data/lib/pixelforce_recipes/legacy_recipes/base.rb +0 -24
  26. data/lib/pixelforce_recipes/legacy_recipes/logrotate.rb +0 -14
  27. data/lib/pixelforce_recipes/legacy_recipes/puma.rb +0 -26
  28. data/lib/pixelforce_recipes/legacy_recipes/resque.rb +0 -22
  29. data/lib/pixelforce_recipes/legacy_recipes/resque_scheduler.rb +0 -22
  30. data/lib/pixelforce_recipes/legacy_recipes/sidekiq.rb +0 -23
  31. data/lib/pixelforce_recipes/legacy_recipes/unicorn.rb +0 -29
  32. /data/lib/pixelforce_recipes/{capistrano_3_recipes → recipes/capistrano_recipes}/base.rb +0 -0
  33. /data/lib/pixelforce_recipes/{capistrano_3_recipes → recipes/capistrano_recipes}/logrotate.rb +0 -0
  34. /data/lib/pixelforce_recipes/{capistrano_3_recipes → recipes/capistrano_recipes}/puma.rb +0 -0
  35. /data/lib/pixelforce_recipes/{capistrano_3_recipes → recipes/capistrano_recipes}/resque.rb +0 -0
  36. /data/lib/pixelforce_recipes/{capistrano_3_recipes → recipes/capistrano_recipes}/resque_scheduler.rb +0 -0
  37. /data/lib/pixelforce_recipes/{capistrano_3_recipes → recipes/capistrano_recipes}/sidekiq.rb +0 -0
  38. /data/lib/pixelforce_recipes/{capistrano_3_recipes → recipes/capistrano_recipes}/supervisor.rb +0 -0
  39. /data/lib/pixelforce_recipes/{capistrano_3_recipes → recipes/capistrano_recipes}/unicorn.rb +0 -0
  40. /data/lib/pixelforce_recipes/{templates → recipes/templates}/logrotate.erb +0 -0
  41. /data/lib/pixelforce_recipes/{templates → recipes/templates}/nginx_config.erb +0 -0
  42. /data/lib/pixelforce_recipes/{templates → recipes/templates}/nginx_puma_config.erb +0 -0
  43. /data/lib/pixelforce_recipes/{templates → recipes/templates}/puma.rb.erb +0 -0
  44. /data/lib/pixelforce_recipes/{templates → recipes/templates}/puma_systemd.erb +0 -0
  45. /data/lib/pixelforce_recipes/{templates → recipes/templates}/resque_init.erb +0 -0
  46. /data/lib/pixelforce_recipes/{templates → recipes/templates}/resque_scheduler_init.erb +0 -0
  47. /data/lib/pixelforce_recipes/{templates → recipes/templates}/resque_scheduler_supervisor.erb +0 -0
  48. /data/lib/pixelforce_recipes/{templates → recipes/templates}/resque_supervisor.erb +0 -0
  49. /data/lib/pixelforce_recipes/{templates → recipes/templates}/sidekiq_init.erb +0 -0
  50. /data/lib/pixelforce_recipes/{templates → recipes/templates}/sidekiq_supervisor.erb +0 -0
  51. /data/lib/pixelforce_recipes/{templates → recipes/templates}/sidekiq_systemd.erb +0 -0
  52. /data/lib/pixelforce_recipes/{templates → recipes/templates}/supervisor.erb +0 -0
  53. /data/lib/pixelforce_recipes/{templates → recipes/templates}/unicorn_init.erb +0 -0
  54. /data/lib/pixelforce_recipes/{templates → recipes/templates}/unicorn_supervisor.erb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a764d72cb9b7327a363e11a1d7072a024210e7b1982caf2b1f250947ba9247f5
4
- data.tar.gz: b6b145951cabd3a24d6f8b5fcabd40d9f5113855d2278554a89ed8b4a7bd7f63
3
+ metadata.gz: 1c4622a9930f37bf7a6d4c838353530001d955274f227f0e39ae93bba1149310
4
+ data.tar.gz: '0948deb727cbbc63d7bd265e7f8592e499b56baae33dfb590897f0f9d4c65fea'
5
5
  SHA512:
6
- metadata.gz: 022a8ee0b5db8f7e1b75cf9f5c7b3dc11492fd72bd5acc6d94ea4826543a5310996c97f62a5a7e491291b169fb57f0ad4c3417dc2c83eb373fd57546cb8c1bb1
7
- data.tar.gz: e958d348959954184ee4e85e9d6e9e1a7dc20b0bc5b01a8b7d401a082638709a137c9731c5bfcf989f0d1baf73d07d7c5cdb15f1fc750e5f77f7664168b706f1
6
+ metadata.gz: 1a84130e71ac22e81f44ff242ac44e51479f7e07ba56897c26c608afc278b141b1050b95ef89bc94c522a824785db712a8d90c08192d7beeb108fce58d3f6a42
7
+ data.tar.gz: 77f52f112dcea55cb8da6fa43485c476790357c7935b0b5dd1515b2bc806990e58989e5f2e924e7c9b6c59980920628c606ed70cb433cd6ff5e64c14ac708882
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  /pkg
2
+ .DS_Store
data/Gemfile.lock CHANGED
@@ -1,47 +1,242 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pixelforce_recipes (3.9.2)
5
- capistrano (> 2.0.0)
4
+ pixelforce_recipes (4.0.3)
5
+ capistrano (> 3.0.0)
6
+ devise
7
+ devise_token_auth
8
+ elbas
6
9
 
7
10
  GEM
8
11
  remote: https://rubygems.org/
9
12
  specs:
10
- airbrussh (1.4.1)
13
+ actioncable (7.1.5.1)
14
+ actionpack (= 7.1.5.1)
15
+ activesupport (= 7.1.5.1)
16
+ nio4r (~> 2.0)
17
+ websocket-driver (>= 0.6.1)
18
+ zeitwerk (~> 2.6)
19
+ actionmailbox (7.1.5.1)
20
+ actionpack (= 7.1.5.1)
21
+ activejob (= 7.1.5.1)
22
+ activerecord (= 7.1.5.1)
23
+ activestorage (= 7.1.5.1)
24
+ activesupport (= 7.1.5.1)
25
+ mail (>= 2.7.1)
26
+ net-imap
27
+ net-pop
28
+ net-smtp
29
+ actionmailer (7.1.5.1)
30
+ actionpack (= 7.1.5.1)
31
+ actionview (= 7.1.5.1)
32
+ activejob (= 7.1.5.1)
33
+ activesupport (= 7.1.5.1)
34
+ mail (~> 2.5, >= 2.5.4)
35
+ net-imap
36
+ net-pop
37
+ net-smtp
38
+ rails-dom-testing (~> 2.2)
39
+ actionpack (7.1.5.1)
40
+ actionview (= 7.1.5.1)
41
+ activesupport (= 7.1.5.1)
42
+ nokogiri (>= 1.8.5)
43
+ racc
44
+ rack (>= 2.2.4)
45
+ rack-session (>= 1.0.1)
46
+ rack-test (>= 0.6.3)
47
+ rails-dom-testing (~> 2.2)
48
+ rails-html-sanitizer (~> 1.6)
49
+ actiontext (7.1.5.1)
50
+ actionpack (= 7.1.5.1)
51
+ activerecord (= 7.1.5.1)
52
+ activestorage (= 7.1.5.1)
53
+ activesupport (= 7.1.5.1)
54
+ globalid (>= 0.6.0)
55
+ nokogiri (>= 1.8.5)
56
+ actionview (7.1.5.1)
57
+ activesupport (= 7.1.5.1)
58
+ builder (~> 3.1)
59
+ erubi (~> 1.11)
60
+ rails-dom-testing (~> 2.2)
61
+ rails-html-sanitizer (~> 1.6)
62
+ activejob (7.1.5.1)
63
+ activesupport (= 7.1.5.1)
64
+ globalid (>= 0.3.6)
65
+ activemodel (7.1.5.1)
66
+ activesupport (= 7.1.5.1)
67
+ activerecord (7.1.5.1)
68
+ activemodel (= 7.1.5.1)
69
+ activesupport (= 7.1.5.1)
70
+ timeout (>= 0.4.0)
71
+ activestorage (7.1.5.1)
72
+ actionpack (= 7.1.5.1)
73
+ activejob (= 7.1.5.1)
74
+ activerecord (= 7.1.5.1)
75
+ activesupport (= 7.1.5.1)
76
+ marcel (~> 1.0)
77
+ activesupport (7.1.5.1)
78
+ base64
79
+ benchmark (>= 0.3)
80
+ bigdecimal
81
+ concurrent-ruby (~> 1.0, >= 1.0.2)
82
+ connection_pool (>= 2.2.5)
83
+ drb
84
+ i18n (>= 1.6, < 2)
85
+ logger (>= 1.4.2)
86
+ minitest (>= 5.1)
87
+ mutex_m
88
+ securerandom (>= 0.3)
89
+ tzinfo (~> 2.0)
90
+ airbrussh (1.5.3)
11
91
  sshkit (>= 1.6.1, != 1.7.0)
12
- aws-eventstream (1.2.0)
13
- aws-partitions (1.628.0)
14
- aws-sdk-autoscaling (1.80.0)
15
- aws-sdk-core (~> 3, >= 3.127.0)
16
- aws-sigv4 (~> 1.1)
17
- aws-sdk-core (3.145.0)
18
- aws-eventstream (~> 1, >= 1.0.2)
19
- aws-partitions (~> 1, >= 1.525.0)
20
- aws-sigv4 (~> 1.1)
92
+ aws-eventstream (1.4.0)
93
+ aws-partitions (1.1120.0)
94
+ aws-sdk-autoscaling (1.138.0)
95
+ aws-sdk-core (~> 3, >= 3.225.0)
96
+ aws-sigv4 (~> 1.5)
97
+ aws-sdk-core (3.226.1)
98
+ aws-eventstream (~> 1, >= 1.3.0)
99
+ aws-partitions (~> 1, >= 1.992.0)
100
+ aws-sigv4 (~> 1.9)
101
+ base64
21
102
  jmespath (~> 1, >= 1.6.1)
22
- aws-sdk-ec2 (1.331.0)
23
- aws-sdk-core (~> 3, >= 3.127.0)
24
- aws-sigv4 (~> 1.1)
25
- aws-sigv4 (1.5.1)
103
+ logger
104
+ aws-sdk-ec2 (1.532.0)
105
+ aws-sdk-core (~> 3, >= 3.225.0)
106
+ aws-sigv4 (~> 1.5)
107
+ aws-sigv4 (1.12.1)
26
108
  aws-eventstream (~> 1, >= 1.0.2)
27
- capistrano (3.17.1)
109
+ base64 (0.3.0)
110
+ bcrypt (3.1.20)
111
+ benchmark (0.4.1)
112
+ bigdecimal (3.2.2)
113
+ builder (3.3.0)
114
+ capistrano (3.19.2)
28
115
  airbrussh (>= 1.0.0)
29
116
  i18n
30
117
  rake (>= 10.0.0)
31
118
  sshkit (>= 1.9.0)
32
- concurrent-ruby (1.1.10)
119
+ cgi (0.5.0)
120
+ concurrent-ruby (1.3.5)
121
+ connection_pool (2.5.3)
122
+ crass (1.0.6)
123
+ date (3.4.1)
124
+ devise (4.9.4)
125
+ bcrypt (~> 3.0)
126
+ orm_adapter (~> 0.1)
127
+ railties (>= 4.1.0)
128
+ responders
129
+ warden (~> 1.2.3)
130
+ devise_token_auth (1.2.5)
131
+ bcrypt (~> 3.0)
132
+ devise (> 3.5.2, < 5)
133
+ rails (>= 4.2.0, < 8.1)
33
134
  diff-lcs (1.2.5)
135
+ drb (2.2.3)
34
136
  elbas (3.0.4)
35
137
  aws-sdk-autoscaling (~> 1)
36
138
  aws-sdk-ec2 (~> 1)
37
139
  capistrano (> 3)
38
- i18n (1.12.0)
140
+ erb (4.0.4)
141
+ cgi (>= 0.3.3)
142
+ erubi (1.13.1)
143
+ globalid (1.2.1)
144
+ activesupport (>= 6.1)
145
+ i18n (1.14.7)
39
146
  concurrent-ruby (~> 1.0)
40
- jmespath (1.6.1)
41
- net-scp (1.2.1)
42
- net-ssh (>= 2.6.5)
43
- net-ssh (7.0.1)
147
+ io-console (0.8.0)
148
+ irb (1.15.2)
149
+ pp (>= 0.6.0)
150
+ rdoc (>= 4.0.0)
151
+ reline (>= 0.4.2)
152
+ jmespath (1.6.2)
153
+ logger (1.7.0)
154
+ loofah (2.24.1)
155
+ crass (~> 1.0.2)
156
+ nokogiri (>= 1.12.0)
157
+ mail (2.8.1)
158
+ mini_mime (>= 0.1.1)
159
+ net-imap
160
+ net-pop
161
+ net-smtp
162
+ marcel (1.0.4)
163
+ mini_mime (1.1.5)
164
+ mini_portile2 (2.8.9)
165
+ minitest (5.25.5)
166
+ mutex_m (0.3.0)
167
+ net-imap (0.4.22)
168
+ date
169
+ net-protocol
170
+ net-pop (0.1.2)
171
+ net-protocol
172
+ net-protocol (0.2.2)
173
+ timeout
174
+ net-scp (4.1.0)
175
+ net-ssh (>= 2.6.5, < 8.0.0)
176
+ net-sftp (4.0.0)
177
+ net-ssh (>= 5.0.0, < 8.0.0)
178
+ net-smtp (0.5.1)
179
+ net-protocol
180
+ net-ssh (7.3.0)
181
+ nio4r (2.7.4)
182
+ nokogiri (1.17.2)
183
+ mini_portile2 (~> 2.8.2)
184
+ racc (~> 1.4)
185
+ orm_adapter (0.5.0)
186
+ ostruct (0.6.2)
187
+ pp (0.6.2)
188
+ prettyprint
189
+ prettyprint (0.2.0)
190
+ psych (5.2.6)
191
+ date
192
+ stringio
193
+ racc (1.8.1)
194
+ rack (3.1.16)
195
+ rack-session (2.1.1)
196
+ base64 (>= 0.1.0)
197
+ rack (>= 3.0.0)
198
+ rack-test (2.2.0)
199
+ rack (>= 1.3)
200
+ rackup (2.2.1)
201
+ rack (>= 3)
202
+ rails (7.1.5.1)
203
+ actioncable (= 7.1.5.1)
204
+ actionmailbox (= 7.1.5.1)
205
+ actionmailer (= 7.1.5.1)
206
+ actionpack (= 7.1.5.1)
207
+ actiontext (= 7.1.5.1)
208
+ actionview (= 7.1.5.1)
209
+ activejob (= 7.1.5.1)
210
+ activemodel (= 7.1.5.1)
211
+ activerecord (= 7.1.5.1)
212
+ activestorage (= 7.1.5.1)
213
+ activesupport (= 7.1.5.1)
214
+ bundler (>= 1.15.0)
215
+ railties (= 7.1.5.1)
216
+ rails-dom-testing (2.3.0)
217
+ activesupport (>= 5.0.0)
218
+ minitest
219
+ nokogiri (>= 1.6)
220
+ rails-html-sanitizer (1.6.2)
221
+ loofah (~> 2.21)
222
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
223
+ railties (7.1.5.1)
224
+ actionpack (= 7.1.5.1)
225
+ activesupport (= 7.1.5.1)
226
+ irb
227
+ rackup (>= 1.0.0)
228
+ rake (>= 12.2)
229
+ thor (~> 1.0, >= 1.2.2)
230
+ zeitwerk (~> 2.6)
44
231
  rake (13.0.1)
232
+ rdoc (6.14.1)
233
+ erb
234
+ psych (>= 4.0.0)
235
+ reline (0.6.1)
236
+ io-console (~> 0.5)
237
+ responders (3.1.1)
238
+ actionpack (>= 5.2)
239
+ railties (>= 5.2)
45
240
  rspec (3.5.0)
46
241
  rspec-core (~> 3.5.0)
47
242
  rspec-expectations (~> 3.5.0)
@@ -55,19 +250,35 @@ GEM
55
250
  diff-lcs (>= 1.2.0, < 2.0)
56
251
  rspec-support (~> 3.5.0)
57
252
  rspec-support (3.5.0)
58
- sshkit (1.21.3)
253
+ securerandom (0.3.2)
254
+ sshkit (1.24.0)
255
+ base64
256
+ logger
59
257
  net-scp (>= 1.1.2)
258
+ net-sftp (>= 2.1.2)
60
259
  net-ssh (>= 2.8.0)
260
+ ostruct
261
+ stringio (3.1.7)
262
+ thor (1.3.2)
263
+ timeout (0.4.3)
264
+ tzinfo (2.0.6)
265
+ concurrent-ruby (~> 1.0)
266
+ warden (1.2.9)
267
+ rack (>= 2.0.9)
268
+ websocket-driver (0.8.0)
269
+ base64
270
+ websocket-extensions (>= 0.1.0)
271
+ websocket-extensions (0.1.5)
272
+ zeitwerk (2.6.18)
61
273
 
62
274
  PLATFORMS
63
275
  ruby
64
276
 
65
277
  DEPENDENCIES
66
278
  bundler (~> 2.1)
67
- elbas
68
279
  pixelforce_recipes!
69
280
  rake (~> 13.0)
70
281
  rspec (~> 3.0)
71
282
 
72
283
  BUNDLED WITH
73
- 2.2.10
284
+ 2.2.33
@@ -0,0 +1,110 @@
1
+ module Admin
2
+ module Api
3
+ class AdminBaseController < ApplicationController
4
+ include DeviseTokenAuth::Concerns::SetUserByToken
5
+ include ResponseHandler
6
+ include RequestHeaderHandler
7
+ include ExceptionHandler
8
+
9
+ layout false
10
+
11
+ before_action :authenticate_admin_user!
12
+ before_action :format_params
13
+ before_action :prepare_pagination_params
14
+ after_action :track_admin_request
15
+
16
+ def authenticate_admin_user!
17
+ authenticate_admin_api_admin_user!
18
+ end
19
+
20
+ def current_admin_user
21
+ current_admin_api_admin_user
22
+ end
23
+
24
+ def log_target
25
+ @log_target
26
+ end
27
+
28
+ def admin_action_on_user_id
29
+ @admin_action_on_user_id = if log_target.present?
30
+ if log_target.is_a?(User)
31
+ log_target.id
32
+ else
33
+ log_target.user_id
34
+ end
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def track_admin_request
41
+ unless params[:action] == 'index' || params[:action] == 'show'
42
+ ahoy.track 'AdminLog', {
43
+ params: request.filtered_parameters,
44
+ url: request.original_url,
45
+ response: response.status
46
+ }
47
+ end
48
+ end
49
+
50
+ def set_response_format
51
+ if request.format.to_s != 'text/csv'
52
+ request.format = :json
53
+ self.content_type = 'application/json'
54
+ end
55
+ end
56
+
57
+ def pagination_headers(collection, item_name)
58
+ headers['Content-Range'] = "#{item_name} #{collection.offset_value}-#{collection.offset_value + collection.limit_value - 1}/#{collection.total_count}"
59
+ headers['Access-Control-Expose-Headers'] = 'Content-Range'
60
+ end
61
+
62
+ def pagination_headers_for_dropdown(item_name)
63
+ headers['Content-Range'] = "#{item_name} 0-999/1000"
64
+ headers['Access-Control-Expose-Headers'] = 'Content-Range'
65
+ end
66
+
67
+ def default_per_page
68
+ 10
69
+ end
70
+
71
+ def keywords
72
+ keyword = params[:filter].try(:[], :keyword)
73
+ if keyword.present?
74
+ @keywords = keyword.split(/,| */).reject(&:blank?).map { |value| "%#{value.strip}%" }
75
+ else
76
+ []
77
+ end
78
+ end
79
+
80
+ def export_resource_csv(resources, headers)
81
+ resources = resources.except(:limit, :offset)
82
+ table_name = resources.table_name
83
+ csv_data = CSV.generate(headers: true) do |csv|
84
+ csv << headers.map(&:titleize)
85
+ resources.find_each do |resource|
86
+ csv << headers.map { |header| resource.send(header.parameterize.to_sym) }
87
+ end
88
+ end
89
+ send_data csv_data, filename: "#{table_name}-#{Date.today}.csv"
90
+ end
91
+
92
+ def prepare_pagination_params
93
+ if params[:range].present? && params[:range].is_a?(Array) && params[:range].length == 2
94
+ beginning_offset = params[:range][0].to_i
95
+ end_offset = params[:range][1].to_i
96
+ per_page = end_offset - beginning_offset + 1
97
+ params[:perPage] = per_page
98
+ params[:page] = (beginning_offset / per_page) + 1
99
+ end
100
+ end
101
+
102
+ def format_params
103
+ if request.method_symbol == :get
104
+ params[:filter] = ActionController::Parameters.new(JSON.parse(params[:filter])) if params[:filter].present? && params[:filter].is_a?(String)
105
+ params[:range] = JSON.parse(params[:range]) if params[:range].present? && params[:range].is_a?(String)
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,26 @@
1
+ module Admin
2
+ module Api
3
+ class AppVersionsController < Admin::Api::AdminBaseController
4
+ def show
5
+ app_version = AppVersion.last
6
+ app_version ||= AppVersion.create!
7
+ render json: app_version.as_json(only: %i[id ios_minimum_version_number android_minimum_version_number])
8
+ end
9
+
10
+ def update
11
+ app_version = AppVersion.find(params[:id])
12
+ if app_version.update(app_version_params)
13
+ render json: app_version.as_json(only: %i[id ios_minimum_version_number android_minimum_version_number])
14
+ else
15
+ render_error(400, nil, app_version.errors)
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def app_version_params
22
+ params.permit(:ios_minimum_version_number, :android_minimum_version_number)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ module Admin
2
+ module Api
3
+ class AvailableModulesController < AdminBaseController
4
+ def index
5
+ render json: [
6
+ {
7
+ "id": 1,
8
+ "name": 'Dashboard',
9
+ "path": '/dashboard'
10
+ },
11
+ {
12
+ "id": 2,
13
+ "name": 'Users',
14
+ "path": '/users'
15
+ }
16
+ ]
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,74 @@
1
+ module Api
2
+ class BaseController < ApplicationController
3
+ include DeviseTokenAuth::Concerns::SetUserByToken
4
+ include ResponseHandler
5
+ include RequestHeaderHandler
6
+ include ExceptionHandler
7
+
8
+ protect_from_forgery with: :null_session
9
+
10
+ before_action :authenticate_user!
11
+ before_action :minimum_version_check!
12
+ before_action :set_user_timezone
13
+ before_action :create_user_devices!
14
+
15
+ after_action :track_request
16
+
17
+ private
18
+
19
+ def create_user_devices!
20
+ if current_user.present? && device_headers[:device_token].present?
21
+ user_device = UserDevice.find_or_initialize_by(device_token: device_headers[:device_token])
22
+
23
+ if user_device.persisted? && user_device.user_id != current_user.id
24
+ user_device.destroy!
25
+ user_device = UserDevice.new(device_token: device_headers[:device_token])
26
+ end
27
+
28
+ user_device.user_id = current_user.id
29
+ user_device.app_version = device_headers[:app_version]
30
+ user_device.platform = device_headers[:platform]
31
+ user_device.device_model = device_headers[:device_model]
32
+ user_device.os_version = device_headers[:os_version]
33
+ user_device.app_build_version = device_headers[:app_build_version]
34
+ user_device.save!
35
+ end
36
+ end
37
+
38
+ def set_user_timezone
39
+ if user_timezone && current_user && current_user.timezone != user_timezone
40
+ current_user.update(timezone: user_timezone)
41
+ end
42
+ end
43
+
44
+ def user_timezone
45
+ @user_timezone ||= device_headers[:user_timezone]
46
+ end
47
+
48
+ def minimum_version_check!
49
+ app_version = device_headers[:app_version]
50
+ platform = device_headers[:platform]
51
+
52
+ if app_version.present? && platform.present?
53
+ current_app_version = AppVersion.order(id: :desc).first
54
+
55
+ if current_app_version.present?
56
+ minimum_version = current_app_version.minimum_version(platform)
57
+
58
+ if minimum_version.present? && Gem::Version.new(app_version) < Gem::Version.new(minimum_version)
59
+ render_error(426, I18n.t('api.errors.upgrade_app_version'))
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ def track_request
66
+ api_version = request.path.split('/')[2]
67
+ ahoy.track "ApiRequest::#{api_version}", {
68
+ params: request.filtered_parameters,
69
+ url: request.original_url,
70
+ response: response.status
71
+ }
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,12 @@
1
+ module Api
2
+ module V1
3
+ class HealthCheckController < Api::BaseController
4
+ skip_after_action :track_request
5
+ skip_before_action :authenticate_user!
6
+
7
+ def index
8
+ render_success
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :null_session
3
+ skip_before_action :verify_authenticity_token, if: :json_request?
4
+
5
+ private
6
+
7
+ def json_request?
8
+ request.format.json?
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ class Auth::PasswordsController < Devise::PasswordsController
2
+ protected
3
+
4
+ def after_resetting_password_path_for(_resource)
5
+ reset_password_success_path
6
+ end
7
+ end
File without changes
@@ -0,0 +1,54 @@
1
+ module ExceptionHandler
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ rescue_from StandardError do |e|
6
+ notify_error(e, airbrake_notify: true)
7
+ render_error(500, I18n.t('errors.server_error'))
8
+ end
9
+
10
+ rescue_from ActiveRecord::RecordNotFound do |e|
11
+ notify_error(e)
12
+ render_error(404, I18n.t('errors.record_not_found'))
13
+ end
14
+
15
+ rescue_from ActiveRecord::RecordInvalid do |e|
16
+ notify_error(e)
17
+ render_error(422, I18n.t('errors.record_invalid'))
18
+ end
19
+
20
+ rescue_from ActionController::ParameterMissing do |e|
21
+ notify_error(e)
22
+ render_error(404, I18n.t('errors.record_invalid'))
23
+ end
24
+
25
+ rescue_from JSON::ParserError do |e|
26
+ notify_error(e)
27
+ render_error(404, I18n.t('errors.record_invalid'))
28
+ end
29
+
30
+ rescue_from ActiveRecord::RecordNotUnique do |e|
31
+ notify_error(e)
32
+ render_error(404, I18n.t('errors.record_not_unique'))
33
+ end
34
+
35
+ private
36
+
37
+ def notify_error(error, airbrake_notify: false)
38
+ airbrake_notify(error) if airbrake_notify
39
+ raise_error(error)
40
+ end
41
+
42
+ def raise_error(error)
43
+ if Rails.env.test? || Rails.env.development?
44
+ raise error
45
+ end
46
+ end
47
+
48
+ def airbrake_notify(error)
49
+ if Rails.env.production? || Rails.env.staging?
50
+ Airbrake.notify(error)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,35 @@
1
+ module RequestHeaderHandler
2
+ extend ActiveSupport::Concern
3
+
4
+ def cloudfront_headers
5
+ @cloudfront_headers ||= {
6
+ cloudfront_viewer_address: request.headers['CloudFront-Viewer-Address'],
7
+ cloudfront_viewer_country: request.headers['CloudFront-Viewer-Country'],
8
+ cloudfront_is_ios_viewer: request.headers['CloudFront-Is-Ios-Viewer'],
9
+ cloudfront_is_tablet_viewer: request.headers['CloudFront-Is-Tablet-Viewer'],
10
+ cloudfront_viewer_country_name: request.headers['CloudFront-Viewer-Country-Name'],
11
+ cloudfront_is_mobile_viewer: request.headers['CloudFront-Is-Mobile-Viewer'],
12
+ cloudfront_is_smarttv_viewer: request.headers['CloudFront-Is-Smarttv-Viewer'],
13
+ cloudfront_viewer_country_region: request.headers['CloudFront-Viewer-Country-Region'],
14
+ cloudfront_is_android_viewer: request.headers['CloudFront-Is-Android-Viewer'],
15
+ cloudfront_viewer_country_region_name: request.headers['CloudFront-Viewer-Country-Region-Name'],
16
+ cloudfront_viewer_city: request.headers['CloudFront-Viewer-City'],
17
+ cloudfront_viewer_latitude: request.headers['CloudFront-Viewer-Latitude'],
18
+ cloudfront_viewer_longitude: request.headers['CloudFront-Viewer-Longitude'],
19
+ cloudfront_viewer_postal_code: request.headers['CloudFront-Viewer-Postal-Code'],
20
+ cloudfront_is_desktop_viewer: request.headers['CloudFront-Is-Desktop-Viewer']
21
+ }
22
+ end
23
+
24
+ def device_headers
25
+ @device_headers ||= {
26
+ app_version: request.headers['HTTP_X_APP_VERSION'],
27
+ platform: request.headers['HTTP_X_PLATFORM'],
28
+ device_model: request.headers['HTTP_X_DEVICE_MODEL'],
29
+ os_version: request.headers['HTTP_X_OS_VERSION'],
30
+ app_build_version: request.headers['HTTP_X_APP_BUILD_VERSION'],
31
+ device_token: request.headers['HTTP_X_DEVICE_TOKEN'],
32
+ user_timezone: request.headers['HTTP_X_USER_TIMEZONE']
33
+ }
34
+ end
35
+ end
@@ -0,0 +1,51 @@
1
+ module ResponseHandler
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_action :config_default_response_settings
6
+ layout false
7
+ end
8
+
9
+ def config_default_response_settings
10
+ set_response_format
11
+ end
12
+
13
+ def set_response_format
14
+ if request.format.to_s != 'text/csv'
15
+ request.format = :json
16
+ self.content_type = 'application/json'
17
+ end
18
+ end
19
+
20
+ def render_success
21
+ render json: {}, status: :ok
22
+ end
23
+
24
+ def render_no_content
25
+ render json: {}, status: :no_content
26
+ end
27
+
28
+ def render_error(status, message, errors = nil, source: nil, meta: {})
29
+ response = {
30
+ 'status' => status.to_s,
31
+ 'source' => source,
32
+ 'errors' => {},
33
+ 'meta' => meta
34
+ }
35
+
36
+ if errors.is_a?(ActiveModel::Errors)
37
+ errors.each do |error|
38
+ attribute = error.attribute.to_s
39
+ error_message = error.message
40
+ response['errors'][attribute] ||= []
41
+ response['errors'][attribute] << error_message
42
+ end
43
+ elsif errors.is_a?(Hash)
44
+ response['errors'] = errors
45
+ else
46
+ response['errors'] = { 'server' => message }
47
+ end
48
+
49
+ render json: response, status: status
50
+ end
51
+ end
@@ -0,0 +1,36 @@
1
+ class PagesController < ApplicationController
2
+ layout 'rails_template'
3
+
4
+ def index; end
5
+
6
+ def fonts_page; end
7
+
8
+ def spinners_page; end
9
+
10
+ def animations_page; end
11
+
12
+ def global_notice_page
13
+ flash.now[:notice] = 'Here is a notice flash message!'
14
+ flash.now[:success] = 'Here is a success flash message!'
15
+ flash.now[:warning] = 'Here is a warning flash message!'
16
+ flash.now[:error] = 'Here is an error flash message!'
17
+ end
18
+
19
+ def new
20
+ @template_model = TemplateModel.new
21
+ end
22
+
23
+ def create
24
+ @template_model = TemplateModel.new(template_model_params)
25
+ if @template_model.save
26
+ flash[:success] = 'Template has been created successfully.'
27
+ redirect_to new_template_model_path
28
+ else
29
+ render :new
30
+ end
31
+ end
32
+
33
+ def template_model_params
34
+ params.require(:template_model).permit(:first_name, :last_name, :email, :dob, :gender, :message, :level, :active)
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ class UsersController < ApplicationController
2
+ def reset_password_success; end
3
+ end
@@ -0,0 +1,5 @@
1
+ module PixelforceRecipes
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace PixelforceRecipes
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module PixelforceRecipes
2
+ class Railtie < ::Rails::Railtie
3
+ end
4
+ end
@@ -1,7 +1,7 @@
1
1
  namespace :elbas do
2
2
  desc 'Sync files before creating AMI'
3
3
  task :sync do
4
- on roles(:app) do
4
+ on release_roles(:all) do
5
5
  execute "sync"
6
6
  end
7
7
  end
@@ -0,0 +1,4 @@
1
+ require "pixelforce_recipes/version"
2
+ require "capistrano"
3
+
4
+ Dir[File.expand_path("#{File.dirname(__FILE__)}/recipes/capistrano_recipes/*.rb")].each {|file| require file }
@@ -1,3 +1,3 @@
1
1
  module PixelforceRecipes
2
- VERSION = '3.9.2'
2
+ VERSION = '4.0.3'
3
3
  end
@@ -1,10 +1,8 @@
1
- require "pixelforce_recipes/version"
2
- require "capistrano"
1
+ require 'rails'
2
+ require_relative 'pixelforce_recipes/railtie'
3
+ require_relative 'pixelforce_recipes/engine'
4
+ require_relative 'pixelforce_recipes/version'
3
5
 
4
- if defined?(Capistrano::VERSION)
5
- if Capistrano::VERSION.to_s.split('.').first.to_i >= 3
6
- Dir[File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/*.rb")].each {|file| require file }
7
- else
8
- Dir[File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/*.rb")].each {|file| require file }
9
- end
10
- end
6
+ module PixelforceRecipes
7
+
8
+ end
@@ -22,6 +22,8 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 2.1"
23
23
  spec.add_development_dependency "rake", "~> 13.0"
24
24
  spec.add_development_dependency "rspec", "~> 3.0"
25
- spec.add_development_dependency "elbas"
26
- spec.add_dependency(%q<capistrano>, ["> 2.0.0"])
25
+ spec.add_dependency "elbas"
26
+ spec.add_dependency 'devise'
27
+ spec.add_dependency 'devise_token_auth'
28
+ spec.add_dependency(%q<capistrano>, ["> 3.0.0"])
27
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixelforce_recipes
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.2
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Zhang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-13 00:00:00.000000000 Z
11
+ date: 2025-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -59,7 +59,35 @@ dependencies:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- type: :development
62
+ type: :runtime
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: devise
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: devise_token_auth
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
@@ -72,14 +100,14 @@ dependencies:
72
100
  requirements:
73
101
  - - ">"
74
102
  - !ruby/object:Gem::Version
75
- version: 2.0.0
103
+ version: 3.0.0
76
104
  type: :runtime
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
108
  - - ">"
81
109
  - !ruby/object:Gem::Version
82
- version: 2.0.0
110
+ version: 3.0.0
83
111
  description: Write a longer description or delete this line.
84
112
  email:
85
113
  - bzbnhang@gmail.com
@@ -94,40 +122,49 @@ files:
94
122
  - LICENSE.txt
95
123
  - README.md
96
124
  - Rakefile
125
+ - app/controllers/admin/api/admin_base_controller.rb
126
+ - app/controllers/admin/api/app_versions_controller.rb
127
+ - app/controllers/admin/api/available_modules_controller.rb
128
+ - app/controllers/api/base_controller.rb
129
+ - app/controllers/api/v1/health_check_controller.rb
130
+ - app/controllers/application_controller.rb
131
+ - app/controllers/auth/passwords_controller.rb
132
+ - app/controllers/concerns/.keep
133
+ - app/controllers/concerns/exception_handler.rb
134
+ - app/controllers/concerns/request_header_handler.rb
135
+ - app/controllers/concerns/response_handler.rb
136
+ - app/controllers/pages_controller.rb
137
+ - app/controllers/users_controller.rb
97
138
  - bin/console
98
139
  - bin/setup
99
140
  - lib/pixelforce_recipes.rb
100
- - lib/pixelforce_recipes/capistrano_3_recipes/base.rb
101
- - lib/pixelforce_recipes/capistrano_3_recipes/elbas.rb
102
- - lib/pixelforce_recipes/capistrano_3_recipes/logrotate.rb
103
- - lib/pixelforce_recipes/capistrano_3_recipes/puma.rb
104
- - lib/pixelforce_recipes/capistrano_3_recipes/resque.rb
105
- - lib/pixelforce_recipes/capistrano_3_recipes/resque_scheduler.rb
106
- - lib/pixelforce_recipes/capistrano_3_recipes/sidekiq.rb
107
- - lib/pixelforce_recipes/capistrano_3_recipes/supervisor.rb
108
- - lib/pixelforce_recipes/capistrano_3_recipes/unicorn.rb
109
- - lib/pixelforce_recipes/legacy_recipes/base.rb
110
- - lib/pixelforce_recipes/legacy_recipes/logrotate.rb
111
- - lib/pixelforce_recipes/legacy_recipes/puma.rb
112
- - lib/pixelforce_recipes/legacy_recipes/resque.rb
113
- - lib/pixelforce_recipes/legacy_recipes/resque_scheduler.rb
114
- - lib/pixelforce_recipes/legacy_recipes/sidekiq.rb
115
- - lib/pixelforce_recipes/legacy_recipes/unicorn.rb
116
- - lib/pixelforce_recipes/templates/logrotate.erb
117
- - lib/pixelforce_recipes/templates/nginx_config.erb
118
- - lib/pixelforce_recipes/templates/nginx_puma_config.erb
119
- - lib/pixelforce_recipes/templates/puma.rb.erb
120
- - lib/pixelforce_recipes/templates/puma_systemd.erb
121
- - lib/pixelforce_recipes/templates/resque_init.erb
122
- - lib/pixelforce_recipes/templates/resque_scheduler_init.erb
123
- - lib/pixelforce_recipes/templates/resque_scheduler_supervisor.erb
124
- - lib/pixelforce_recipes/templates/resque_supervisor.erb
125
- - lib/pixelforce_recipes/templates/sidekiq_init.erb
126
- - lib/pixelforce_recipes/templates/sidekiq_supervisor.erb
127
- - lib/pixelforce_recipes/templates/sidekiq_systemd.erb
128
- - lib/pixelforce_recipes/templates/supervisor.erb
129
- - lib/pixelforce_recipes/templates/unicorn_init.erb
130
- - lib/pixelforce_recipes/templates/unicorn_supervisor.erb
141
+ - lib/pixelforce_recipes/engine.rb
142
+ - lib/pixelforce_recipes/railtie.rb
143
+ - lib/pixelforce_recipes/recipes.rb
144
+ - lib/pixelforce_recipes/recipes/capistrano_recipes/base.rb
145
+ - lib/pixelforce_recipes/recipes/capistrano_recipes/elbas.rb
146
+ - lib/pixelforce_recipes/recipes/capistrano_recipes/logrotate.rb
147
+ - lib/pixelforce_recipes/recipes/capistrano_recipes/puma.rb
148
+ - lib/pixelforce_recipes/recipes/capistrano_recipes/resque.rb
149
+ - lib/pixelforce_recipes/recipes/capistrano_recipes/resque_scheduler.rb
150
+ - lib/pixelforce_recipes/recipes/capistrano_recipes/sidekiq.rb
151
+ - lib/pixelforce_recipes/recipes/capistrano_recipes/supervisor.rb
152
+ - lib/pixelforce_recipes/recipes/capistrano_recipes/unicorn.rb
153
+ - lib/pixelforce_recipes/recipes/templates/logrotate.erb
154
+ - lib/pixelforce_recipes/recipes/templates/nginx_config.erb
155
+ - lib/pixelforce_recipes/recipes/templates/nginx_puma_config.erb
156
+ - lib/pixelforce_recipes/recipes/templates/puma.rb.erb
157
+ - lib/pixelforce_recipes/recipes/templates/puma_systemd.erb
158
+ - lib/pixelforce_recipes/recipes/templates/resque_init.erb
159
+ - lib/pixelforce_recipes/recipes/templates/resque_scheduler_init.erb
160
+ - lib/pixelforce_recipes/recipes/templates/resque_scheduler_supervisor.erb
161
+ - lib/pixelforce_recipes/recipes/templates/resque_supervisor.erb
162
+ - lib/pixelforce_recipes/recipes/templates/sidekiq_init.erb
163
+ - lib/pixelforce_recipes/recipes/templates/sidekiq_supervisor.erb
164
+ - lib/pixelforce_recipes/recipes/templates/sidekiq_systemd.erb
165
+ - lib/pixelforce_recipes/recipes/templates/supervisor.erb
166
+ - lib/pixelforce_recipes/recipes/templates/unicorn_init.erb
167
+ - lib/pixelforce_recipes/recipes/templates/unicorn_supervisor.erb
131
168
  - lib/pixelforce_recipes/version.rb
132
169
  - pixelforce_recipes.gemspec
133
170
  homepage: https://github.com/BenZhang/pixelforce_recipes
@@ -149,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
186
  - !ruby/object:Gem::Version
150
187
  version: '0'
151
188
  requirements: []
152
- rubygems_version: 3.1.6
189
+ rubygems_version: 3.2.33
153
190
  signing_key:
154
191
  specification_version: 4
155
192
  summary: Write a short summary, because Rubygems requires one.
@@ -1,24 +0,0 @@
1
- if Capistrano::Configuration.instance(false)
2
-
3
- Capistrano::Configuration.instance(true).load do |instance|
4
-
5
- def template(from, to)
6
- erb = File.read(File.expand_path("../../templates/#{from}", __FILE__))
7
- put ERB.new(erb).result(binding), to
8
- end
9
-
10
- def set_default(name, *args, &block)
11
- set(name, *args, &block) unless exists?(name)
12
- end
13
-
14
- namespace :deploy do
15
- desc "Install everything onto the server"
16
- task :install do
17
- run "#{sudo} apt-get -y update"
18
- run "#{sudo} apt-get -y install curl git-core python-software-properties build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion"
19
- end
20
- end
21
-
22
- end
23
-
24
- end
@@ -1,14 +0,0 @@
1
- if Capistrano::Configuration.instance(false)
2
-
3
- Capistrano::Configuration.instance(true).load do |instance|
4
-
5
- namespace :logrotate do
6
-
7
- desc "Setup logrotate configuration for this application"
8
- task :setup, roles: :app do
9
- template "logrotate.erb", "/tmp/logrotate"
10
- run "#{sudo} mv /tmp/logrotate /etc/logrotate.d/#{application}"
11
- end
12
- end
13
- end
14
- end
@@ -1,26 +0,0 @@
1
- if Capistrano::Configuration.instance(false)
2
-
3
- Capistrano::Configuration.instance(true).load do |instance|
4
-
5
- namespace :puma do
6
-
7
- desc "Setup puma configuration for this application"
8
- task :setup, roles: :web do
9
- template "puma_init.erb", "/tmp/puma"
10
- run "#{sudo} mv /tmp/puma /etc/init.d/#{application}"
11
- run "#{sudo} chmod +x /etc/init.d/#{application}"
12
- run "#{sudo} update-rc.d #{application} defaults"
13
- template "nginx_puma_config.erb", "/tmp/nginx_puma_config"
14
- run "#{sudo} mv /tmp/nginx_puma_config /etc/nginx/sites-enabled/#{application}"
15
- end
16
- # after "deploy:setup", "nginx:setup"
17
-
18
- %w[start stop restart].each do |command|
19
- desc "#{command} puma"
20
- task command, roles: :web do
21
- run "/etc/init.d/#{application} #{command}"
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,22 +0,0 @@
1
- if Capistrano::Configuration.instance(false)
2
- Capistrano::Configuration.instance(true).load do |instance|
3
- namespace :resque do
4
- desc "Install resque"
5
-
6
- desc "Setup resque configuration for this application"
7
- task :setup, roles: :resque do
8
- template "resque_init.erb", "/tmp/resque"
9
- run "#{sudo} mv /tmp/resque /etc/init.d/resque"
10
- run "#{sudo} chmod +x /etc/init.d/resque"
11
- run "#{sudo} update-rc.d resque defaults"
12
- end
13
-
14
- %w[start stop restart].each do |command|
15
- desc "#{command} resque"
16
- task command do
17
- run "/etc/init.d/resque #{command}"
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,22 +0,0 @@
1
- if Capistrano::Configuration.instance(false)
2
- Capistrano::Configuration.instance(true).load do |instance|
3
- namespace :resque_scheduler do
4
- desc "Install resque scheduler"
5
-
6
- desc "Setup resque scheduler configuration for this application"
7
- task :setup, roles: :resque do
8
- template "resque_scheduler_init.erb", "/tmp/resque_scheduler"
9
- run "#{sudo} mv /tmp/resque_scheduler /etc/init.d/resque_scheduler"
10
- run "#{sudo} chmod +x /etc/init.d/resque_scheduler"
11
- run "#{sudo} update-rc.d resque_scheduler defaults"
12
- end
13
-
14
- %w[start stop restart].each do |command|
15
- desc "#{command} resque scheduler"
16
- task command do
17
- run "/etc/init.d/resque_scheduler #{command}"
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,23 +0,0 @@
1
- if Capistrano::Configuration.instance(false)
2
- Capistrano::Configuration.instance(true).load do |instance|
3
- namespace :sidekiq do
4
- desc "Install sidekiq"
5
-
6
- desc "Setup sidekiq configuration for this application"
7
- task :setup, roles: :sidekiq do
8
- template "sidekiq_init.erb", "/tmp/sidekiq"
9
- run "#{sudo} mv /tmp/sidekiq /etc/init.d/sidekiq"
10
- run "#{sudo} chmod +x /etc/init.d/sidekiq"
11
- run "#{sudo} update-rc.d sidekiq defaults"
12
- end
13
- # after "deploy:setup", "nginx:setup"
14
-
15
- %w[start stop restart].each do |command|
16
- desc "#{command} sidekiq"
17
- task command do
18
- run "/etc/init.d/sidekiq #{command}"
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,29 +0,0 @@
1
- if Capistrano::Configuration.instance(false)
2
-
3
- Capistrano::Configuration.instance(true).load do |instance|
4
-
5
- namespace :unicorn do
6
- desc "Install unicorn"
7
-
8
- desc "Setup unicorn configuration for this application"
9
- task :setup, roles: :web do
10
- template "unicorn_init.erb", "/tmp/unicorn"
11
- run "#{sudo} mv /tmp/unicorn /etc/init.d/#{application}"
12
- run "#{sudo} chmod +x /etc/init.d/#{application}"
13
- run "#{sudo} update-rc.d #{application} defaults"
14
- template "nginx_config.erb", "/tmp/nginx_config"
15
- run "#{sudo} mv /tmp/nginx_config /etc/nginx/sites-enabled/#{application}"
16
- end
17
- # after "deploy:setup", "nginx:setup"
18
-
19
- %w[start stop restart].each do |command|
20
- desc "#{command} unicorn"
21
- task command, roles: :web do
22
- run "/etc/init.d/#{application} #{command}"
23
- end
24
- end
25
- end
26
-
27
- end
28
-
29
- end