nexus_seed 0.2.8 → 0.2.9

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
  SHA256:
3
- metadata.gz: 7c30412d463327ee535c5abe6862a2c7079726562cd6bc1dcb359e5e719c242c
4
- data.tar.gz: 1dbed102d6cb21ee5eb8c2958ef844f011303f529413d5e75d11b8ae0cd932e6
3
+ metadata.gz: 3d0602fbc47d7d2441dfd389ee099c07c163ad9f9614733b44ade4c694e9de3b
4
+ data.tar.gz: 0eabcd944bafa8a1088e0bdf30d93fb5343f39fbbcb23eab0cef31a04754dfca
5
5
  SHA512:
6
- metadata.gz: c3dbcec4ca06afbda2e4f64f1ad6324f99be0a350e43cc25ce83d0db40cc576e1a8861fb92851e2d0cef066335903633d764a672f9141be969b4d4fcdde8316f
7
- data.tar.gz: 5bee9f4dfd6b6634a17af5cbf60d17b38199a30629d16718339dd98843a0c1a3307f643c2475124a9ec2690ff8708ebfd87912cb03b1f4c01743b8b5e6c3b91b
6
+ metadata.gz: df29415b25122e1320693f78e36cf91b799943d5b21b1bea59f5ee23d188d2fd635345f1e8f90f73fef55477a2b951ef4aff955d6dea3a7382ea75bf9f5c706a
7
+ data.tar.gz: d7452164c0c606570e77146fc884450eb955e0bc14ee742f42061f0232e0da00aed365b3779212d54e656698d1736d21717054d6ea4689c20f08054ec6e28f90
data/README.md CHANGED
@@ -1,3 +1,75 @@
1
1
  # nexus_seed
2
2
 
3
3
  Common rails application seeding logic.
4
+
5
+ # Running
6
+
7
+ ## Running tasks on deploy
8
+
9
+ Task files must be placed in `/lib/tasks/seed_#{name}.rake`
10
+
11
+ Set task name in helm values e.g. for a `common` seed task:
12
+
13
+ ```
14
+ helm:
15
+ values:
16
+ rails:
17
+ seedTasks:
18
+ - common
19
+ ```
20
+
21
+ Configure the post deploy hook in `devspace.yaml` and set `COMPONENT` appropriately:
22
+
23
+ ```
24
+ hooks:
25
+ - name: post-deploy-seed-task-hook
26
+ events: [ "after:deploy" ]
27
+ command: |-
28
+ docker run --rm --pull always registry.nexusmods.com/nexus-mods/devops/tools/seed_task_start:stable cat seed_task_start.sh |
29
+ NAMESPACE=${devspace.namespace} COMPONENT=api bash
30
+ ```
31
+
32
+ ## Running tasks manually
33
+
34
+ Run `common` seed task with default options:
35
+
36
+ `bundle exec rake seed_common:run`
37
+
38
+ Options are `[:retry_limit, :sleep_interval]`
39
+
40
+ E.g. to retry 100 times every 3 seconds:
41
+
42
+ `bundle exec rake seed_common:run[100,3]`
43
+
44
+ # Local gem development
45
+
46
+ Steps to run this gem from local sources in one the nexus 'staged build' rails components:
47
+
48
+ ## Copy gem sources to component
49
+
50
+ ```
51
+ cd ~/nexus-api
52
+ cp -r ../nexus_seed .
53
+ ```
54
+
55
+ ## Adjust component Dockerfile to include gem sources
56
+
57
+ Within stage 1, append a COPY after the Gemfile copy:
58
+
59
+ ```
60
+ COPY --chown=nexus:nexus Gemfile* ./
61
+ COPY --chown=nexus:nexus nexus_seed/ ./nexus_seed/
62
+ ```
63
+
64
+ Within stage 2, append a COPY after the bundle copy:
65
+
66
+ ```
67
+ COPY --from=stage1 /usr/local/bundle /usr/local/bundle
68
+ COPY --from=stage1 /app/nexus_seed/ /app/nexus_seed/
69
+ ```
70
+
71
+ ## Adjust Gemfile to use local path
72
+
73
+ ```
74
+ gem 'nexus_seed', :path => "/app/nexus_seed"
75
+ ```
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module NexusSeed
3
- # Leave this as 0.2.8 in order for CI process to replace with the tagged version.
4
- VERSION = '0.2.8'
3
+ # Leave this as 0.2.9 in order for CI process to replace with the tagged version.
4
+ VERSION = '0.2.9'
5
5
  end
data/lib/nexus_seed.rb CHANGED
@@ -7,10 +7,9 @@ require 'nexus_seed/base'
7
7
 
8
8
  module NexusSeed
9
9
  # defaults
10
- @@retry_limit = 0
10
+ @@retry_limit = 12
11
11
  @@sleep_interval = 5
12
12
  @@retries = 0
13
- @@logger = SemanticLogger::Logger.new('NexusSeed')
14
13
 
15
14
  # override this method with your specific requirement
16
15
  def requires
@@ -18,6 +17,7 @@ module NexusSeed
18
17
  end
19
18
 
20
19
  def run
20
+ logger.info('Run with options:', limit: retry_limit, interval: sleep_interval)
21
21
  logger.measure_info('Total seed run.') do
22
22
  _run_internal
23
23
  end
@@ -26,6 +26,8 @@ module NexusSeed
26
26
  # recursively called until requirement is met or the limit is reached
27
27
  def _run_internal
28
28
  if Rails.env.test? || Rails.env.development?
29
+
30
+ logger.info("Starting run attempt #{retries + 1}")
29
31
  if requires
30
32
  NexusSeed::Base.transaction do
31
33
  seed
@@ -84,7 +86,7 @@ module NexusSeed
84
86
  end
85
87
 
86
88
  def logger
87
- @@logger
89
+ @logger ||= SemanticLogger::Logger.new('NexusSeed')
88
90
  end
89
91
 
90
92
  def task_options(opts = {})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexus_seed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johnathon Harris