nexus_seed 0.2.8 → 0.2.9
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.
- checksums.yaml +4 -4
- data/README.md +72 -0
- data/lib/nexus_seed/version.rb +2 -2
- data/lib/nexus_seed.rb +5 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d0602fbc47d7d2441dfd389ee099c07c163ad9f9614733b44ade4c694e9de3b
|
4
|
+
data.tar.gz: 0eabcd944bafa8a1088e0bdf30d93fb5343f39fbbcb23eab0cef31a04754dfca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
```
|
data/lib/nexus_seed/version.rb
CHANGED
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 =
|
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
|
-
|
89
|
+
@logger ||= SemanticLogger::Logger.new('NexusSeed')
|
88
90
|
end
|
89
91
|
|
90
92
|
def task_options(opts = {})
|